Skip to content

Commit 59b914a

Browse files
committed
Create crossbeam scope
1 parent 87dbb28 commit 59b914a

File tree

1 file changed

+78
-75
lines changed

1 file changed

+78
-75
lines changed

tests/compiletest.rs

Lines changed: 78 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -49,92 +49,95 @@ fn run_tests(mode: Mode, path: &str, target: &str) {
4949
let total = AtomicUsize::default();
5050
let skipped = AtomicUsize::default();
5151

52-
while let Some(path) = todo.pop() {
53-
// Collect everything inside directories
54-
if path.is_dir() {
55-
for entry in grab_entries(&path) {
56-
todo.push(entry);
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;
5760
}
58-
continue;
59-
}
60-
// Only look at .rs files
61-
if let Some(ext) = path.extension() {
62-
if ext != "rs" {
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());
6374
continue;
6475
}
65-
} else {
66-
continue;
67-
}
68-
total.fetch_add(1, Ordering::Relaxed);
69-
// Read rules for skipping from file
70-
if ignore_file(&path, &target) {
71-
skipped.fetch_add(1, Ordering::Relaxed);
72-
eprintln!("{} .. {}", path.display(), "skipped".yellow());
73-
continue;
74-
}
7576

76-
// Run miri
77-
let mut miri = Command::new(miri_path());
78-
miri.args(flags.iter());
79-
miri.arg(&path);
80-
miri.env("RUSTC_BACKTRACE", "0");
81-
extract_env(&mut miri, &path);
82-
let output = miri.output().expect("could not execute miri");
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");
8384

84-
let mut ok = match (output.status.success(), mode) {
85-
(false, Mode::UB) | (false, Mode::Panic) | (true, Mode::Pass) => true,
86-
(true, Mode::Panic) | (true, Mode::UB) | (false, Mode::Pass) => false,
87-
};
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+
};
8889

89-
// Check output files (if any)
90-
let stderr = std::str::from_utf8(&output.stderr).unwrap();
91-
let stderr = normalize(&path, stderr);
92-
let expected_stderr = if let Ok(_) = env::var("MIRI_BLESS") {
93-
if stderr.is_empty() {
94-
let _ = std::fs::remove_file(path.with_extension("stderr"));
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()
95100
} else {
96-
std::fs::write(path.with_extension("stderr"), &stderr).unwrap();
97-
}
98-
stderr.clone()
99-
} else {
100-
let expected_stderr =
101-
std::fs::read_to_string(path.with_extension("stderr")).unwrap_or_default();
102-
ok &= stderr == expected_stderr;
103-
expected_stderr
104-
};
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+
};
106+
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+
};
105122

106-
let stdout = std::str::from_utf8(&output.stdout).unwrap();
107-
let stdout = normalize(&path, stdout);
108-
let expected_stdout = if let Ok(_) = env::var("MIRI_BLESS") {
109-
if stdout.is_empty() {
110-
let _ = std::fs::remove_file(path.with_extension("stdout"));
123+
eprint!("{} .. ", path.display());
124+
if ok {
125+
eprintln!("{}", "ok".green());
111126
} else {
112-
std::fs::write(path.with_extension("stdout"), &stdout).unwrap();
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+
));
113137
}
114-
stdout.clone()
115-
} else {
116-
let expected_stdout =
117-
std::fs::read_to_string(path.with_extension("stdout")).unwrap_or_default();
118-
ok &= stdout == expected_stdout;
119-
expected_stdout
120-
};
121-
122-
eprint!("{} .. ", path.display());
123-
if ok {
124-
eprintln!("{}", "ok".green());
125-
} else {
126-
eprintln!("{}", "FAILED".red().bold());
127-
failures.lock().unwrap().push((
128-
path,
129-
output,
130-
miri,
131-
expected_stderr,
132-
expected_stdout,
133-
stderr,
134-
stdout,
135-
));
136138
}
137-
}
139+
})
140+
.unwrap();
138141

139142
let failures = failures.into_inner().unwrap();
140143
let total = total.load(Ordering::Relaxed);

0 commit comments

Comments
 (0)