Skip to content

Commit d095429

Browse files
committed
Auto merge of #2448 - oli-obk:test_crates_on_their_own, r=RalfJung
Run `pass` tests without building dependencies first fixes #2442 One thing that I'm wondering is if we should do away with running each folder individually and make `ui_test` support running all tests in parallel (so building deps becomes a thread, and all tests needing deps are blocked on it)
2 parents 9f99aa9 + 6f8885e commit d095429

21 files changed

+24
-7
lines changed

tests/compiletest.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ fn miri_path() -> PathBuf {
88
PathBuf::from(option_env!("MIRI").unwrap_or(env!("CARGO_BIN_EXE_miri")))
99
}
1010

11-
fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
11+
fn run_tests(
12+
mode: Mode,
13+
path: &str,
14+
target: Option<String>,
15+
with_dependencies: bool,
16+
) -> Result<()> {
1217
let in_rustc_test_suite = option_env!("RUSTC_STAGE").is_some();
1318

1419
// Add some flags we always want.
@@ -68,7 +73,7 @@ fn run_tests(mode: Mode, path: &str, target: Option<String>) -> Result<()> {
6873
path_filter: path_filter.collect(),
6974
program: miri_path(),
7075
output_conflict_handling,
71-
dependencies_crate_manifest_path: use_std
76+
dependencies_crate_manifest_path: (with_dependencies && use_std)
7277
.then(|| Path::new("test_dependencies").join("Cargo.toml")),
7378
dependency_builder: Some(DependencyBuilder {
7479
program: std::env::var_os("CARGO").unwrap().into(),
@@ -132,7 +137,14 @@ regexes! {
132137
r"[^ ]*/\.?cargo/registry/.*/(.*\.rs)" => "CARGO_REGISTRY/.../$1",
133138
}
134139

135-
fn ui(mode: Mode, path: &str) -> Result<()> {
140+
enum Dependencies {
141+
WithDependencies,
142+
WithoutDependencies,
143+
}
144+
145+
use Dependencies::*;
146+
147+
fn ui(mode: Mode, path: &str, with_dependencies: Dependencies) -> Result<()> {
136148
let target = get_target();
137149

138150
let msg = format!(
@@ -141,7 +153,11 @@ fn ui(mode: Mode, path: &str) -> Result<()> {
141153
);
142154
eprintln!("{}", msg.green().bold());
143155

144-
run_tests(mode, path, target)
156+
let with_dependencies = match with_dependencies {
157+
WithDependencies => true,
158+
WithoutDependencies => false,
159+
};
160+
run_tests(mode, path, target, with_dependencies)
145161
}
146162

147163
fn get_target() -> Option<String> {
@@ -156,9 +172,10 @@ fn main() -> Result<()> {
156172
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
157173
env::set_var("MIRI_TEMP", env::temp_dir());
158174

159-
ui(Mode::Pass, "tests/pass")?;
160-
ui(Mode::Panic, "tests/panic")?;
161-
ui(Mode::Fail, "tests/fail")?;
175+
ui(Mode::Pass, "tests/pass", WithoutDependencies)?;
176+
ui(Mode::Pass, "tests/pass-dep", WithDependencies)?;
177+
ui(Mode::Panic, "tests/panic", WithDependencies)?;
178+
ui(Mode::Fail, "tests/fail", WithDependencies)?;
162179

163180
Ok(())
164181
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)