@@ -7,7 +7,6 @@ extern crate test;
77
88use crate :: common:: { expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS } ;
99use crate :: common:: { CompareMode , Config , Debugger , Mode , PassMode , TestPaths } ;
10- use crate :: util:: logv;
1110use getopts:: Options ;
1211use lazycell:: LazyCell ;
1312use std:: env;
@@ -27,32 +26,15 @@ use self::header::{make_test_description, EarlyProps};
2726mod tests;
2827
2928pub 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;
3332mod json;
3433mod raise_fd_limit;
3534mod read2;
36- pub mod runtest;
35+ mod runtest;
3736pub mod util;
3837
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-
5638pub fn parse_config ( args : Vec < String > ) -> Config {
5739 let mut opts = Options :: new ( ) ;
5840 opts. reqopt ( "" , "compile-lib-path" , "path to host shared libraries" , "PATH" )
@@ -67,6 +49,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
6749 . optflag ( "" , "force-valgrind" , "fail if Valgrind tests cannot be run under Valgrind" )
6850 . optopt ( "" , "run-clang-based-tests-with" , "path to Clang executable" , "PATH" )
6951 . optopt ( "" , "llvm-filecheck" , "path to LLVM's FileCheck binary" , "DIR" )
52+ . reqopt ( "" , "source-root" , "root directory of the project" , "PATH" )
7053 . reqopt ( "" , "src-base" , "directory to scan for test files" , "PATH" )
7154 . reqopt ( "" , "build-base" , "directory to deposit test outputs" , "PATH" )
7255 . reqopt ( "" , "stage-id" , "the target-stage identifier" , "stageN-TARGET" )
@@ -232,10 +215,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
232215 run_clang_based_tests_with : matches. opt_str ( "run-clang-based-tests-with" ) ,
233216 llvm_filecheck : matches. opt_str ( "llvm-filecheck" ) . map ( PathBuf :: from) ,
234217 llvm_bin_dir : matches. opt_str ( "llvm-bin-dir" ) . map ( PathBuf :: from) ,
218+ source_root : opt_path ( matches, "source-root" ) ,
235219 src_base,
236220 build_base : opt_path ( matches, "build-base" ) ,
237221 stage_id : matches. opt_str ( "stage-id" ) . unwrap ( ) ,
238222 mode,
223+ no_expected_comments : false ,
239224 suite : matches. opt_str ( "suite" ) . unwrap ( ) ,
240225 debugger : None ,
241226 run_ignored,
@@ -296,55 +281,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
296281 npm : matches. opt_str ( "npm" ) ,
297282
298283 force_rerun : matches. opt_present ( "force-rerun" ) ,
299-
300284 target_cfg : LazyCell :: new ( ) ,
285+ hooks : Default :: default ( ) ,
301286 }
302287}
303288
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 {
348290 match maybestr {
349291 None => "(none)" . to_owned ( ) ,
350292 Some ( s) => s,
@@ -524,7 +466,11 @@ pub fn make_tests(config: &Config, tests: &mut Vec<test::TestDescAndFn>) {
524466
525467/// Returns a stamp constructed from input files common to all test cases.
526468fn 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 ( ) ;
528474
529475 let mut stamp = Stamp :: from_path ( & config. rustc_path ) ;
530476
@@ -627,6 +573,12 @@ pub fn is_test(file_name: &OsString) -> bool {
627573}
628574
629575fn 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+
630582 let test_path = if config. mode == Mode :: RunMake {
631583 // Parse directives in the Makefile
632584 testpaths. file . join ( "Makefile" )
@@ -648,7 +600,7 @@ fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec<test
648600 let src_file =
649601 std:: fs:: File :: open ( & test_path) . expect ( "open test file to parse ignores" ) ;
650602 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) ;
652604 let mut desc = make_test_description ( config, test_name, & test_path, src_file, cfg) ;
653605 // Ignore tests that already run and are up to date with respect to inputs.
654606 if !config. force_rerun {
@@ -770,10 +722,7 @@ fn make_test_name(
770722 testpaths : & TestPaths ,
771723 revision : Option < & String > ,
772724) -> 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 ( ) ;
777726 let debugger = match config. debugger {
778727 Some ( d) => format ! ( "-{}" , d) ,
779728 None => String :: new ( ) ,
0 commit comments