@@ -12,12 +12,12 @@ extern crate test;
12
12
13
13
use crate :: common:: { output_base_dir, output_relative_path, PanicStrategy } ;
14
14
use crate :: common:: { Config , Mode , TestPaths } ;
15
- use crate :: util:: logv;
15
+ use crate :: util:: { logv, top_level } ;
16
16
use getopts:: Options ;
17
17
use std:: env;
18
18
use std:: ffi:: OsString ;
19
19
use std:: fs;
20
- use std:: io:: { self , ErrorKind } ;
20
+ use std:: io:: { self } ;
21
21
use std:: path:: { Path , PathBuf } ;
22
22
use std:: time:: SystemTime ;
23
23
use test:: ColorConfig ;
@@ -60,7 +60,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
60
60
. optopt ( "" , "llvm-filecheck" , "path to LLVM's FileCheck binary" , "DIR" )
61
61
. optopt ( "" , "src-base" , "directory to scan for test files" , "PATH" )
62
62
. optopt ( "" , "build-base" , "directory to deposit test outputs" , "PATH" )
63
- . optopt ( "" , "stage-id" , "the target-stage identifier" , "stageN-TARGET" )
64
63
. optopt (
65
64
"" ,
66
65
"mode" ,
@@ -137,7 +136,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
137
136
)
138
137
. optflag ( "" , "force-rerun" , "rerun tests even if the inputs are unchanged" )
139
138
. optflag ( "h" , "help" , "show this message" )
140
- . optopt ( "" , "channel" , "current Rust channel" , "CHANNEL" )
141
139
. optopt ( "" , "edition" , "default Rust edition" , "EDITION" ) ;
142
140
143
141
let ( argv0, args_) = args. split_first ( ) . unwrap ( ) ;
@@ -160,10 +158,16 @@ pub fn parse_config(args: Vec<String>) -> Config {
160
158
panic ! ( )
161
159
}
162
160
163
- fn opt_path ( m : & getopts:: Matches , nm : & str ) -> PathBuf {
161
+ fn opt_path ( m : & getopts:: Matches , nm : & str , default : & [ & str ] ) -> PathBuf {
164
162
match m. opt_str ( nm) {
165
163
Some ( s) => PathBuf :: from ( & s) ,
166
- None => panic ! ( "no option (=path) found for {}" , nm) ,
164
+ None => {
165
+ let mut root_folder = top_level ( ) . expect (
166
+ format ! ( "Cannot find root directory. Please provide --{} option." , nm) . as_str ( ) ,
167
+ ) ;
168
+ default. into_iter ( ) . for_each ( |f| root_folder. push ( f) ) ;
169
+ root_folder
170
+ }
167
171
}
168
172
}
169
173
@@ -175,17 +179,17 @@ pub fn parse_config(args: Vec<String>) -> Config {
175
179
Some ( x) => panic ! ( "argument for --color must be auto, always, or never, but found `{}`" , x) ,
176
180
} ;
177
181
178
- let src_base = opt_path ( matches, "src-base" ) ;
182
+ let suite = matches. opt_str ( "suite" ) . unwrap ( ) ;
183
+ let src_base = opt_path ( matches, "src-base" , & [ "tests" , suite. as_str ( ) ] ) ;
179
184
let run_ignored = matches. opt_present ( "ignored" ) ;
180
185
let mode = matches. opt_str ( "mode" ) . unwrap ( ) . parse ( ) . expect ( "invalid mode" ) ;
181
186
182
187
Config {
183
- kani_dir_path : opt_path ( matches, "kani-dir-path" ) ,
188
+ kani_dir_path : opt_path ( matches, "kani-dir-path" , & [ "scripts" ] ) ,
184
189
src_base,
185
- build_base : opt_path ( matches, "build-base" ) ,
186
- stage_id : matches. opt_str ( "stage-id" ) . unwrap ( ) ,
190
+ build_base : opt_path ( matches, "build-base" , & [ "build" , "tests" , suite. as_str ( ) ] ) ,
187
191
mode,
188
- suite : matches . opt_str ( "suite" ) . unwrap ( ) ,
192
+ suite,
189
193
run_ignored,
190
194
filters : matches. free . clone ( ) ,
191
195
filter_exact : matches. opt_present ( "exact" ) ,
@@ -202,7 +206,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
202
206
verbose : matches. opt_present ( "verbose" ) ,
203
207
quiet : matches. opt_present ( "quiet" ) ,
204
208
color,
205
- channel : matches. opt_str ( "channel" ) . unwrap ( ) ,
206
209
edition : matches. opt_str ( "edition" ) ,
207
210
208
211
force_rerun : matches. opt_present ( "force-rerun" ) ,
@@ -214,7 +217,6 @@ pub fn log_config(config: &Config) {
214
217
logv ( c, "configuration:" . to_string ( ) ) ;
215
218
logv ( c, format ! ( "src_base: {:?}" , config. src_base. display( ) ) ) ;
216
219
logv ( c, format ! ( "build_base: {:?}" , config. build_base. display( ) ) ) ;
217
- logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
218
220
logv ( c, format ! ( "mode: {}" , config. mode) ) ;
219
221
logv ( c, format ! ( "run_ignored: {}" , config. run_ignored) ) ;
220
222
logv ( c, format ! ( "filters: {:?}" , config. filters) ) ;
@@ -324,14 +326,14 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
324
326
325
327
pub fn make_tests ( config : & Config , tests : & mut Vec < test:: TestDescAndFn > ) {
326
328
debug ! ( "making tests from {:?}" , config. src_base. display( ) ) ;
327
- let inputs = common_inputs_stamp ( config ) ;
329
+ let inputs = common_inputs_stamp ( ) ;
328
330
collect_tests_from_dir ( config, & config. src_base , & PathBuf :: new ( ) , & inputs, tests)
329
331
. unwrap_or_else ( |_| panic ! ( "Could not read tests from {}" , config. src_base. display( ) ) ) ;
330
332
}
331
333
332
334
/// Returns a stamp constructed from input files common to all test cases.
333
- fn common_inputs_stamp ( config : & Config ) -> Stamp {
334
- let rust_src_dir = config . find_rust_src_root ( ) . expect ( "Could not find Rust source root" ) ;
335
+ fn common_inputs_stamp ( ) -> Stamp {
336
+ let rust_src_dir = top_level ( ) . expect ( "Could not find Rust source root" ) ;
335
337
let kani_bin_path = & rust_src_dir. join ( "target/debug/kani-compiler" ) ;
336
338
337
339
// Create stamp based on the `kani-compiler` binary
@@ -453,16 +455,6 @@ fn is_up_to_date(
453
455
inputs : & Stamp ,
454
456
) -> bool {
455
457
let stamp_name = stamp ( config, testpaths, revision) ;
456
- // Check hash.
457
- let contents = match fs:: read_to_string ( & stamp_name) {
458
- Ok ( f) => f,
459
- Err ( ref e) if e. kind ( ) == ErrorKind :: InvalidData => panic ! ( "Can't read stamp contents" ) ,
460
- Err ( _) => return false ,
461
- } ;
462
- let expected_hash = runtest:: compute_stamp_hash ( config) ;
463
- if contents != expected_hash {
464
- return false ;
465
- }
466
458
// Check timestamps.
467
459
let inputs = inputs. clone ( ) ;
468
460
0 commit comments