@@ -2273,26 +2273,7 @@ impl<'test> TestCx<'test> {
22732273 /// Runs RMC on the test file specified by `self.testpaths.file`. An error
22742274 /// message is printed to stdout if the verification result is not expected.
22752275 fn verify ( & self ) {
2276- // Other modes call self.compile_test(...). However, we cannot call it here for two reasons:
2277- // 1. It calls rustc instead of RMC
2278- // 2. It may pass some options that do not make sense for RMC
2279- // So we create our own command to execute RMC and pass it to self.compose_and_run_compiler(...) directly.
2280- let mut rmc = Command :: new ( "rmc" ) ;
2281- // We cannot pass rustc flags directly to RMC. Instead, we add them
2282- // to the current environment through the `RUSTFLAGS` environment
2283- // variable. RMC recognizes the variable and adds those flags to its
2284- // internal call to rustc.
2285- if !self . props . compile_flags . is_empty ( ) {
2286- rmc. env ( "RUSTFLAGS" , self . props . compile_flags . join ( " " ) ) ;
2287- }
2288- // Pass the test path along with RMC and CBMC flags parsed from comments at the top of the test file.
2289- rmc. args ( & self . props . rmc_flags )
2290- . arg ( "--input" )
2291- . arg ( & self . testpaths . file )
2292- . arg ( "--cbmc-args" )
2293- . args ( & self . props . cbmc_flags ) ;
2294- self . add_rmc_dir_to_path ( & mut rmc) ;
2295- let proc_res = self . compose_and_run_compiler ( rmc, None ) ;
2276+ let proc_res = self . run_rmc ( ) ;
22962277 // If the test file contains expected failures in some locations, ensure
22972278 // that verification does indeed fail in those locations
22982279 if proc_res. stdout . contains ( "EXPECTED FAIL" ) {
@@ -2390,20 +2371,35 @@ impl<'test> TestCx<'test> {
23902371 self . verify_output ( & proc_res, & expected) ;
23912372 }
23922373
2393- /// Runs RMC on the test file specified by `self.testpaths.file`. An error
2394- /// message is printed to stdout if verification output does not contain
2395- /// the expected output in `expected` file.
2396- fn run_expected_test ( & self ) {
2397- // We create our own command for the same reasons listed in `run_rmc_test` method.
2374+ /// Common method used to run RMC on a single file test.
2375+ fn run_rmc ( & self ) -> ProcRes {
2376+ // Other modes call self.compile_test(...). However, we cannot call it here for two reasons:
2377+ // 1. It calls rustc instead of RMC
2378+ // 2. It may pass some options that do not make sense for RMC
2379+ // So we create our own command to execute RMC and pass it to self.compose_and_run_compiler(...) directly.
23982380 let mut rmc = Command :: new ( "rmc" ) ;
2381+ // We cannot pass rustc flags directly to RMC. Instead, we add them
2382+ // to the current environment through the `RUSTFLAGS` environment
2383+ // variable. RMC recognizes the variable and adds those flags to its
2384+ // internal call to rustc.
2385+ if !self . props . compile_flags . is_empty ( ) {
2386+ rmc. env ( "RUSTFLAGS" , self . props . compile_flags . join ( " " ) ) ;
2387+ }
23992388 // Pass the test path along with RMC and CBMC flags parsed from comments at the top of the test file.
24002389 rmc. args ( & self . props . rmc_flags )
24012390 . arg ( "--input" )
24022391 . arg ( & self . testpaths . file )
24032392 . arg ( "--cbmc-args" )
24042393 . args ( & self . props . cbmc_flags ) ;
24052394 self . add_rmc_dir_to_path ( & mut rmc) ;
2406- let proc_res = self . compose_and_run_compiler ( rmc, None ) ;
2395+ self . compose_and_run_compiler ( rmc, None )
2396+ }
2397+
2398+ /// Runs RMC on the test file specified by `self.testpaths.file`. An error
2399+ /// message is printed to stdout if verification output does not contain
2400+ /// the expected output in `expected` file.
2401+ fn run_expected_test ( & self ) {
2402+ let proc_res = self . run_rmc ( ) ;
24072403 let expected =
24082404 fs:: read_to_string ( self . testpaths . file . parent ( ) . unwrap ( ) . join ( "expected" ) ) . unwrap ( ) ;
24092405 self . verify_output ( & proc_res, & expected) ;
@@ -2414,16 +2410,7 @@ impl<'test> TestCx<'test> {
24142410 /// abstraction. At a later stage, it should be possible to add command-line
24152411 /// arguments to test specific abstractions and modules.
24162412 fn run_stub_test ( & self ) {
2417- let mut rmc = Command :: new ( "rmc" ) ;
2418- // Arguments to choose specific abstraction are currently provided as
2419- // as rmc-flags in the test file
2420- rmc. args ( & self . props . rmc_flags )
2421- . arg ( "--input" )
2422- . arg ( & self . testpaths . file )
2423- . arg ( "--cbmc-args" )
2424- . args ( & self . props . cbmc_flags ) ;
2425- self . add_rmc_dir_to_path ( & mut rmc) ;
2426- let proc_res = self . compose_and_run_compiler ( rmc, None ) ;
2413+ let proc_res = self . run_rmc ( ) ;
24272414 if !proc_res. status . success ( ) {
24282415 self . fatal_proc_rec (
24292416 "test failed: expected verification success, got failure" ,
0 commit comments