Skip to content

Commit 41198f3

Browse files
authored
support positional --mp parameter for forge test (#8751)
* support positional --mp parameter * use panic instead
1 parent 9e79f54 commit 41198f3

File tree

1 file changed

+13
-1
lines changed
  • crates/forge/bin/cmd/test

1 file changed

+13
-1
lines changed

crates/forge/bin/cmd/test/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{install, test::filter::ProjectPathsAwareFilter, watch::WatchArgs};
22
use alloy_primitives::U256;
3-
use clap::Parser;
3+
use clap::{Parser, ValueHint};
44
use eyre::Result;
55
use forge::{
66
decode::decode_console_logs,
@@ -32,6 +32,7 @@ use foundry_config::{
3232
value::{Dict, Map},
3333
Metadata, Profile, Provider,
3434
},
35+
filter::GlobMatcher,
3536
get_available_profiles, Config,
3637
};
3738
use foundry_debugger::Debugger;
@@ -58,6 +59,10 @@ foundry_config::merge_impl_figment_convert!(TestArgs, opts, evm_opts);
5859
#[derive(Clone, Debug, Parser)]
5960
#[command(next_help_heading = "Test options")]
6061
pub struct TestArgs {
62+
/// The contract file you want to test, it's a shortcut for --match-path.
63+
#[arg(value_hint = ValueHint::FilePath)]
64+
pub path: Option<GlobMatcher>,
65+
6166
/// Run a test in the debugger.
6267
///
6368
/// The argument passed to this flag is the name of the test function you want to run, and it
@@ -634,6 +639,13 @@ impl TestArgs {
634639
if self.rerun {
635640
filter.test_pattern = last_run_failures(config);
636641
}
642+
if filter.path_pattern.is_some() {
643+
if self.path.is_some() {
644+
panic!("Can not supply both --match-path and |path|");
645+
}
646+
} else {
647+
filter.path_pattern = self.path.clone();
648+
}
637649
filter.merge_with_config(config)
638650
}
639651

0 commit comments

Comments
 (0)