@@ -49,92 +49,98 @@ fn run_tests(mode: Mode, path: &str, target: &str) {
4949 let total = AtomicUsize :: default ( ) ;
5050 let skipped = AtomicUsize :: default ( ) ;
5151
52- crossbeam:: scope ( |_f| {
53- while let Some ( path) = todo. pop ( ) {
54- // Collect everything inside directories
55- if path. is_dir ( ) {
56- for entry in grab_entries ( & path) {
57- todo. push ( entry) ;
58- }
59- continue ;
60- }
61- // Only look at .rs files
62- if let Some ( ext) = path. extension ( ) {
63- if ext != "rs" {
64- continue ;
65- }
66- } else {
67- continue ;
68- }
69- total. fetch_add ( 1 , Ordering :: Relaxed ) ;
70- // Read rules for skipping from file
71- if ignore_file ( & path, & target) {
72- skipped. fetch_add ( 1 , Ordering :: Relaxed ) ;
73- eprintln ! ( "{} .. {}" , path. display( ) , "skipped" . yellow( ) ) ;
74- continue ;
75- }
52+ crossbeam:: scope ( |s| {
53+ for _ in 0 ..num_cpus:: get ( ) {
54+ s. spawn ( |_| {
55+ while let Some ( path) = todo. pop ( ) {
56+ // Collect everything inside directories
57+ if path. is_dir ( ) {
58+ for entry in grab_entries ( & path) {
59+ todo. push ( entry) ;
60+ }
61+ continue ;
62+ }
63+ // Only look at .rs files
64+ if let Some ( ext) = path. extension ( ) {
65+ if ext != "rs" {
66+ continue ;
67+ }
68+ } else {
69+ continue ;
70+ }
71+ total. fetch_add ( 1 , Ordering :: Relaxed ) ;
72+ // Read rules for skipping from file
73+ if ignore_file ( & path, & target) {
74+ skipped. fetch_add ( 1 , Ordering :: Relaxed ) ;
75+ eprintln ! ( "{} .. {}" , path. display( ) , "skipped" . yellow( ) ) ;
76+ continue ;
77+ }
7678
77- // Run miri
78- let mut miri = Command :: new ( miri_path ( ) ) ;
79- miri. args ( flags. iter ( ) ) ;
80- miri. arg ( & path) ;
81- miri. env ( "RUSTC_BACKTRACE" , "0" ) ;
82- extract_env ( & mut miri, & path) ;
83- let output = miri. output ( ) . expect ( "could not execute miri" ) ;
79+ // Run miri
80+ let mut miri = Command :: new ( miri_path ( ) ) ;
81+ miri. args ( flags. iter ( ) ) ;
82+ miri. arg ( & path) ;
83+ miri. env ( "RUSTC_BACKTRACE" , "0" ) ;
84+ extract_env ( & mut miri, & path) ;
85+ let output = miri. output ( ) . expect ( "could not execute miri" ) ;
8486
85- let mut ok = match ( output. status . success ( ) , mode) {
86- ( false , Mode :: UB ) | ( false , Mode :: Panic ) | ( true , Mode :: Pass ) => true ,
87- ( true , Mode :: Panic ) | ( true , Mode :: UB ) | ( false , Mode :: Pass ) => false ,
88- } ;
87+ let mut ok = match ( output. status . success ( ) , mode) {
88+ ( false , Mode :: UB ) | ( false , Mode :: Panic ) | ( true , Mode :: Pass ) => true ,
89+ ( true , Mode :: Panic ) | ( true , Mode :: UB ) | ( false , Mode :: Pass ) => false ,
90+ } ;
8991
90- // Check output files (if any)
91- let stderr = std:: str:: from_utf8 ( & output. stderr ) . unwrap ( ) ;
92- let stderr = normalize ( & path, stderr) ;
93- let expected_stderr = if let Ok ( _) = env:: var ( "MIRI_BLESS" ) {
94- if stderr. is_empty ( ) {
95- let _ = std:: fs:: remove_file ( path. with_extension ( "stderr" ) ) ;
96- } else {
97- std:: fs:: write ( path. with_extension ( "stderr" ) , & stderr) . unwrap ( ) ;
98- }
99- stderr. clone ( )
100- } else {
101- let expected_stderr =
102- std:: fs:: read_to_string ( path. with_extension ( "stderr" ) ) . unwrap_or_default ( ) ;
103- ok &= stderr == expected_stderr;
104- expected_stderr
105- } ;
92+ // Check output files (if any)
93+ let stderr = std:: str:: from_utf8 ( & output. stderr ) . unwrap ( ) ;
94+ let stderr = normalize ( & path, stderr) ;
95+ let expected_stderr = if let Ok ( _) = env:: var ( "MIRI_BLESS" ) {
96+ if stderr. is_empty ( ) {
97+ let _ = std:: fs:: remove_file ( path. with_extension ( "stderr" ) ) ;
98+ } else {
99+ std:: fs:: write ( path. with_extension ( "stderr" ) , & stderr) . unwrap ( ) ;
100+ }
101+ stderr. clone ( )
102+ } else {
103+ let expected_stderr =
104+ std:: fs:: read_to_string ( path. with_extension ( "stderr" ) )
105+ . unwrap_or_default ( ) ;
106+ ok &= stderr == expected_stderr;
107+ expected_stderr
108+ } ;
106109
107- let stdout = std:: str:: from_utf8 ( & output. stdout ) . unwrap ( ) ;
108- let stdout = normalize ( & path, stdout) ;
109- let expected_stdout = if let Ok ( _) = env:: var ( "MIRI_BLESS" ) {
110- if stdout. is_empty ( ) {
111- let _ = std:: fs:: remove_file ( path. with_extension ( "stdout" ) ) ;
112- } else {
113- std:: fs:: write ( path. with_extension ( "stdout" ) , & stdout) . unwrap ( ) ;
114- }
115- stdout. clone ( )
116- } else {
117- let expected_stdout =
118- std:: fs:: read_to_string ( path. with_extension ( "stdout" ) ) . unwrap_or_default ( ) ;
119- ok &= stdout == expected_stdout;
120- expected_stdout
121- } ;
110+ let stdout = std:: str:: from_utf8 ( & output. stdout ) . unwrap ( ) ;
111+ let stdout = normalize ( & path, stdout) ;
112+ let expected_stdout = if let Ok ( _) = env:: var ( "MIRI_BLESS" ) {
113+ if stdout. is_empty ( ) {
114+ let _ = std:: fs:: remove_file ( path. with_extension ( "stdout" ) ) ;
115+ } else {
116+ std:: fs:: write ( path. with_extension ( "stdout" ) , & stdout) . unwrap ( ) ;
117+ }
118+ stdout. clone ( )
119+ } else {
120+ let expected_stdout =
121+ std:: fs:: read_to_string ( path. with_extension ( "stdout" ) )
122+ . unwrap_or_default ( ) ;
123+ ok &= stdout == expected_stdout;
124+ expected_stdout
125+ } ;
122126
123- eprint ! ( "{} .. " , path. display( ) ) ;
124- if ok {
125- eprintln ! ( "{}" , "ok" . green( ) ) ;
126- } else {
127- eprintln ! ( "{}" , "FAILED" . red( ) . bold( ) ) ;
128- failures. lock ( ) . unwrap ( ) . push ( (
129- path,
130- output,
131- miri,
132- expected_stderr,
133- expected_stdout,
134- stderr,
135- stdout,
136- ) ) ;
137- }
127+ eprint ! ( "{} .. " , path. display( ) ) ;
128+ if ok {
129+ eprintln ! ( "{}" , "ok" . green( ) ) ;
130+ } else {
131+ eprintln ! ( "{}" , "FAILED" . red( ) . bold( ) ) ;
132+ failures. lock ( ) . unwrap ( ) . push ( (
133+ path,
134+ output,
135+ miri,
136+ expected_stderr,
137+ expected_stdout,
138+ stderr,
139+ stdout,
140+ ) ) ;
141+ }
142+ }
143+ } ) ;
138144 }
139145 } )
140146 . unwrap ( ) ;
0 commit comments