@@ -7,7 +7,6 @@ extern crate test;
7
7
8
8
use crate :: common:: { expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS } ;
9
9
use crate :: common:: { CompareMode , Config , Debugger , Mode , PassMode , TestPaths } ;
10
- use crate :: util:: logv;
11
10
use getopts:: Options ;
12
11
use lazycell:: LazyCell ;
13
12
use std:: env;
@@ -27,32 +26,15 @@ use self::header::{make_test_description, EarlyProps};
27
26
mod tests;
28
27
29
28
pub mod common;
30
- pub mod compute_diff;
31
- pub mod errors;
32
- pub mod header;
29
+ mod compute_diff;
30
+ mod errors;
31
+ mod header;
33
32
mod json;
34
33
mod raise_fd_limit;
35
34
mod read2;
36
- pub mod runtest;
35
+ mod runtest;
37
36
pub mod util;
38
37
39
- fn main ( ) {
40
- tracing_subscriber:: fmt:: init ( ) ;
41
-
42
- let config = parse_config ( env:: args ( ) . collect ( ) ) ;
43
-
44
- if config. valgrind_path . is_none ( ) && config. force_valgrind {
45
- panic ! ( "Can't find Valgrind to run Valgrind tests" ) ;
46
- }
47
-
48
- if !config. has_tidy && config. mode == Mode :: Rustdoc {
49
- eprintln ! ( "warning: `tidy` is not installed; diffs will not be generated" ) ;
50
- }
51
-
52
- log_config ( & config) ;
53
- run_tests ( config) ;
54
- }
55
-
56
38
pub fn parse_config ( args : Vec < String > ) -> Config {
57
39
let mut opts = Options :: new ( ) ;
58
40
opts. reqopt ( "" , "compile-lib-path" , "path to host shared libraries" , "PATH" )
@@ -67,6 +49,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
67
49
. optflag ( "" , "force-valgrind" , "fail if Valgrind tests cannot be run under Valgrind" )
68
50
. optopt ( "" , "run-clang-based-tests-with" , "path to Clang executable" , "PATH" )
69
51
. optopt ( "" , "llvm-filecheck" , "path to LLVM's FileCheck binary" , "DIR" )
52
+ . reqopt ( "" , "source-root" , "root directory of the project" , "PATH" )
70
53
. reqopt ( "" , "src-base" , "directory to scan for test files" , "PATH" )
71
54
. reqopt ( "" , "build-base" , "directory to deposit test outputs" , "PATH" )
72
55
. reqopt ( "" , "stage-id" , "the target-stage identifier" , "stageN-TARGET" )
@@ -232,10 +215,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
232
215
run_clang_based_tests_with : matches. opt_str ( "run-clang-based-tests-with" ) ,
233
216
llvm_filecheck : matches. opt_str ( "llvm-filecheck" ) . map ( PathBuf :: from) ,
234
217
llvm_bin_dir : matches. opt_str ( "llvm-bin-dir" ) . map ( PathBuf :: from) ,
218
+ source_root : opt_path ( matches, "source-root" ) ,
235
219
src_base,
236
220
build_base : opt_path ( matches, "build-base" ) ,
237
221
stage_id : matches. opt_str ( "stage-id" ) . unwrap ( ) ,
238
222
mode,
223
+ no_expected_comments : false ,
239
224
suite : matches. opt_str ( "suite" ) . unwrap ( ) ,
240
225
debugger : None ,
241
226
run_ignored,
@@ -296,55 +281,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
296
281
npm : matches. opt_str ( "npm" ) ,
297
282
298
283
force_rerun : matches. opt_present ( "force-rerun" ) ,
299
-
300
284
target_cfg : LazyCell :: new ( ) ,
285
+ hooks : Default :: default ( ) ,
301
286
}
302
287
}
303
288
304
- pub fn log_config ( config : & Config ) {
305
- let c = config;
306
- logv ( c, "configuration:" . to_string ( ) ) ;
307
- logv ( c, format ! ( "compile_lib_path: {:?}" , config. compile_lib_path) ) ;
308
- logv ( c, format ! ( "run_lib_path: {:?}" , config. run_lib_path) ) ;
309
- logv ( c, format ! ( "rustc_path: {:?}" , config. rustc_path. display( ) ) ) ;
310
- logv ( c, format ! ( "rustdoc_path: {:?}" , config. rustdoc_path) ) ;
311
- logv ( c, format ! ( "rust_demangler_path: {:?}" , config. rust_demangler_path) ) ;
312
- logv ( c, format ! ( "src_base: {:?}" , config. src_base. display( ) ) ) ;
313
- logv ( c, format ! ( "build_base: {:?}" , config. build_base. display( ) ) ) ;
314
- logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
315
- logv ( c, format ! ( "mode: {}" , config. mode) ) ;
316
- logv ( c, format ! ( "run_ignored: {}" , config. run_ignored) ) ;
317
- logv ( c, format ! ( "filters: {:?}" , config. filters) ) ;
318
- logv ( c, format ! ( "skip: {:?}" , config. skip) ) ;
319
- logv ( c, format ! ( "filter_exact: {}" , config. filter_exact) ) ;
320
- logv (
321
- c,
322
- format ! ( "force_pass_mode: {}" , opt_str( & config. force_pass_mode. map( |m| format!( "{}" , m) ) ) , ) ,
323
- ) ;
324
- logv ( c, format ! ( "runtool: {}" , opt_str( & config. runtool) ) ) ;
325
- logv ( c, format ! ( "host-rustcflags: {:?}" , config. host_rustcflags) ) ;
326
- logv ( c, format ! ( "target-rustcflags: {:?}" , config. target_rustcflags) ) ;
327
- logv ( c, format ! ( "target: {}" , config. target) ) ;
328
- logv ( c, format ! ( "host: {}" , config. host) ) ;
329
- logv ( c, format ! ( "android-cross-path: {:?}" , config. android_cross_path. display( ) ) ) ;
330
- logv ( c, format ! ( "adb_path: {:?}" , config. adb_path) ) ;
331
- logv ( c, format ! ( "adb_test_dir: {:?}" , config. adb_test_dir) ) ;
332
- logv ( c, format ! ( "adb_device_status: {}" , config. adb_device_status) ) ;
333
- logv ( c, format ! ( "ar: {}" , config. ar) ) ;
334
- logv ( c, format ! ( "linker: {:?}" , config. linker) ) ;
335
- logv ( c, format ! ( "verbose: {}" , config. verbose) ) ;
336
- logv ( c, format ! ( "quiet: {}" , config. quiet) ) ;
337
- logv ( c, "\n " . to_string ( ) ) ;
338
- }
339
-
340
- pub fn opt_str ( maybestr : & Option < String > ) -> & str {
341
- match * maybestr {
342
- None => "(none)" ,
343
- Some ( ref s) => s,
344
- }
345
- }
346
-
347
- pub fn opt_str2 ( maybestr : Option < String > ) -> String {
289
+ fn opt_str2 ( maybestr : Option < String > ) -> String {
348
290
match maybestr {
349
291
None => "(none)" . to_owned ( ) ,
350
292
Some ( s) => s,
@@ -524,7 +466,11 @@ pub fn make_tests(config: &Config, tests: &mut Vec<test::TestDescAndFn>) {
524
466
525
467
/// Returns a stamp constructed from input files common to all test cases.
526
468
fn common_inputs_stamp ( config : & Config ) -> Stamp {
527
- let rust_src_dir = config. find_rust_src_root ( ) . expect ( "Could not find Rust source root" ) ;
469
+ if config. force_rerun {
470
+ return Stamp { time : SystemTime :: UNIX_EPOCH } ;
471
+ }
472
+
473
+ let rust_src_dir = config. find_rust_src_root ( ) ;
528
474
529
475
let mut stamp = Stamp :: from_path ( & config. rustc_path ) ;
530
476
@@ -627,6 +573,12 @@ pub fn is_test(file_name: &OsString) -> bool {
627
573
}
628
574
629
575
fn make_test ( config : & Config , testpaths : & TestPaths , inputs : & Stamp ) -> Vec < test:: TestDescAndFn > {
576
+ if let Some ( hook) = & config. hooks . exclude_file {
577
+ if hook ( & testpaths. file ) {
578
+ return Vec :: new ( ) ;
579
+ }
580
+ }
581
+
630
582
let test_path = if config. mode == Mode :: RunMake {
631
583
// Parse directives in the Makefile
632
584
testpaths. file . join ( "Makefile" )
@@ -648,7 +600,7 @@ fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec<test
648
600
let src_file =
649
601
std:: fs:: File :: open ( & test_path) . expect ( "open test file to parse ignores" ) ;
650
602
let cfg = revision. map ( |v| & * * v) ;
651
- let test_name = crate :: make_test_name ( config, testpaths, revision) ;
603
+ let test_name = make_test_name ( config, testpaths, revision) ;
652
604
let mut desc = make_test_description ( config, test_name, & test_path, src_file, cfg) ;
653
605
// Ignore tests that already run and are up to date with respect to inputs.
654
606
if !config. force_rerun {
@@ -770,10 +722,7 @@ fn make_test_name(
770
722
testpaths : & TestPaths ,
771
723
revision : Option < & String > ,
772
724
) -> test:: TestName {
773
- // Print the name of the file, relative to the repository root.
774
- // `src_base` looks like `/path/to/rust/src/test/ui`
775
- let root_directory = config. src_base . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) . parent ( ) . unwrap ( ) ;
776
- let path = testpaths. file . strip_prefix ( root_directory) . unwrap ( ) ;
725
+ let path = testpaths. file . strip_prefix ( & config. source_root ) . unwrap ( ) ;
777
726
let debugger = match config. debugger {
778
727
Some ( d) => format ! ( "-{}" , d) ,
779
728
None => String :: new ( ) ,
0 commit comments