@@ -17,7 +17,7 @@ use forge::{
17
17
MultiContractRunner , MultiContractRunnerBuilder , TestFilter , TestOptions , TestOptionsBuilder ,
18
18
} ;
19
19
use foundry_cli:: {
20
- opts:: CoreBuildArgs ,
20
+ opts:: { CoreBuildArgs , ShellOpts } ,
21
21
utils:: { self , LoadConfig } ,
22
22
} ;
23
23
use foundry_common:: { compile:: ProjectCompiler , evm:: EvmArgs , fs, shell} ;
@@ -178,6 +178,9 @@ pub struct TestArgs {
178
178
/// Print detailed test summary table.
179
179
#[ arg( long, help_heading = "Display options" , requires = "summary" ) ]
180
180
pub detailed : bool ,
181
+
182
+ #[ command( flatten) ]
183
+ shell : ShellOpts ,
181
184
}
182
185
183
186
impl TestArgs {
@@ -991,56 +994,34 @@ fn junit_xml_report(results: &BTreeMap<String, SuiteResult>, verbosity: u8) -> R
991
994
992
995
#[ cfg( test) ]
993
996
mod tests {
994
- use crate :: opts:: { Forge , ForgeSubcommand } ;
995
-
996
997
use super :: * ;
997
998
use foundry_config:: { Chain , InvariantConfig } ;
998
999
use foundry_test_utils:: forgetest_async;
999
1000
1000
1001
#[ test]
1001
1002
fn watch_parse ( ) {
1002
- let args = match Forge :: parse_from ( [ "foundry-cli" , "test" , "-vw" ] ) . cmd {
1003
- ForgeSubcommand :: Test ( args) => args,
1004
- _ => unreachable ! ( ) ,
1005
- } ;
1003
+ let args: TestArgs = TestArgs :: parse_from ( [ "foundry-cli" , "-vw" ] ) ;
1006
1004
assert ! ( args. watch. watch. is_some( ) ) ;
1007
1005
}
1008
1006
1009
1007
#[ test]
1010
1008
fn fuzz_seed ( ) {
1011
- let args = match Forge :: parse_from ( [ "foundry-cli" , "test" , "--fuzz-seed" , "0x10" ] ) . cmd {
1012
- ForgeSubcommand :: Test ( args) => args,
1013
- _ => unreachable ! ( ) ,
1014
- } ;
1009
+ let args: TestArgs = TestArgs :: parse_from ( [ "foundry-cli" , "--fuzz-seed" , "0x10" ] ) ;
1015
1010
assert ! ( args. fuzz_seed. is_some( ) ) ;
1016
1011
}
1017
1012
1018
1013
// <https://github.com/foundry-rs/foundry/issues/5913>
1019
1014
#[ test]
1020
1015
fn fuzz_seed_exists ( ) {
1021
- let args = match Forge :: parse_from ( [
1022
- "foundry-cli" ,
1023
- "test" ,
1024
- "-vvv" ,
1025
- "--gas-report" ,
1026
- "--fuzz-seed" ,
1027
- "0x10" ,
1028
- ] )
1029
- . cmd
1030
- {
1031
- ForgeSubcommand :: Test ( args) => args,
1032
- _ => unreachable ! ( ) ,
1033
- } ;
1016
+ let args: TestArgs =
1017
+ TestArgs :: parse_from ( [ "foundry-cli" , "-vvv" , "--gas-report" , "--fuzz-seed" , "0x10" ] ) ;
1034
1018
assert ! ( args. fuzz_seed. is_some( ) ) ;
1035
1019
}
1036
1020
1037
1021
#[ test]
1038
1022
fn extract_chain ( ) {
1039
1023
let test = |arg : & str , expected : Chain | {
1040
- let args = match Forge :: parse_from ( [ "foundry-cli" , "test" , arg] ) . cmd {
1041
- ForgeSubcommand :: Test ( args) => args,
1042
- _ => unreachable ! ( ) ,
1043
- } ;
1024
+ let args = TestArgs :: parse_from ( [ "foundry-cli" , arg] ) ;
1044
1025
assert_eq ! ( args. evm_opts. env. chain, Some ( expected) ) ;
1045
1026
let ( config, evm_opts) = args. load_config_and_evm_opts ( ) . unwrap ( ) ;
1046
1027
assert_eq ! ( config. chain, Some ( expected) ) ;
@@ -1094,19 +1075,12 @@ contract FooBarTest is DSTest {
1094
1075
)
1095
1076
. unwrap( ) ;
1096
1077
1097
- let args = match Forge :: parse_from( [
1078
+ let args = TestArgs :: parse_from( [
1098
1079
"foundry-cli" ,
1099
- "test" ,
1100
1080
"--gas-report" ,
1101
1081
"--root" ,
1102
1082
& prj. root( ) . to_string_lossy( ) ,
1103
- ] )
1104
- . cmd
1105
- {
1106
- ForgeSubcommand :: Test ( args) => args,
1107
- _ => unreachable!( ) ,
1108
- } ;
1109
-
1083
+ ] ) ;
1110
1084
let outcome = args. run( ) . await . unwrap( ) ;
1111
1085
let gas_report = outcome. gas_report. unwrap( ) ;
1112
1086
0 commit comments