Skip to content

Commit

Permalink
Add examples for forc-test
Browse files Browse the repository at this point in the history
  • Loading branch information
crodas committed Jan 9, 2024
1 parent 8d506c0 commit 94dfb0c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion forc-plugins/forc-doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ anyhow = "1.0.65"
clap = { version = "4.0.18", features = ["derive"] }
colored = "2.0.0"
comrak = "0.16"
forc = { version = "0.48.1", path = "../../forc" }
forc-pkg = { version = "0.48.1", path = "../../forc-pkg" }
forc-util = { version = "0.48.1", path = "../../forc-util" }
horrorshow = "0.8.4"
Expand Down
10 changes: 9 additions & 1 deletion forc-util/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ macro_rules! cli_examples {
let mut proc = std::process::Command::new("cargo");
proc.arg("run");
proc.arg("--bin");
proc.arg(format!("forc-{}", stringify!($command)));
proc.arg(if stringify!($command) == "forc" {
"forc".to_owned()
} else {
format!("forc-{}", stringify!($command))
});
proc.arg("--");

super::parse_args($args).into_iter().for_each(|arg| {
Expand Down Expand Up @@ -127,7 +131,11 @@ macro_rules! cli_examples {
Box::leak( [
$(
$crate::paste::paste! {
if stringify!($command) == "forc" {
format!(" #{}\n forc {}\n\n", stringify!($($description)*), $args )
} else {
format!(" #{}\n forc {} {}\n\n", stringify!($($description)*), stringify!($command), $args )
}
},
)*
].concat().into_boxed_str())
Expand Down
7 changes: 7 additions & 0 deletions forc/src/cli/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ use forc_test::{TestFilter, TestRunnerCount, TestedPackage};
use forc_util::{tx_utils::format_log_receipts, ForcError, ForcResult};
use tracing::info;

forc_util::cli_examples! {
[ Run test => forc "test" => ".*could not find `Forc.toml`.*" ]
[ Run test without any output => forc "test --silent" => "^$" ]
[ Run test without creating or update the lock file => forc "test --locked" => ".*could not find `Forc.toml`.*" ]
}

/// Run the Sway unit tests for the current project.
///
/// NOTE: Previously this command was used to support Rust integration testing, however the
Expand Down Expand Up @@ -42,6 +48,7 @@ pub struct Command {

/// The set of options provided for controlling output of a test.
#[derive(Parser, Debug, Clone)]
#[clap(after_help = help())]
pub struct TestPrintOpts {
#[clap(long = "pretty-print", short = 'r')]
/// Pretty-print the logs emiited from tests.
Expand Down

0 comments on commit 94dfb0c

Please sign in to comment.