Skip to content

Commit

Permalink
Fix compile-test tests to work with the new ui_test crate
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Jul 2, 2023
1 parent 0cbe963 commit de69d55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"src/tools/cargotest",
"src/tools/clippy",
"src/tools/clippy/clippy_dev",
"src/tools/clippy/clippy_test_deps",
"src/tools/compiletest",
"src/tools/error_index_generator",
"src/tools/linkchecker",
Expand Down
22 changes: 5 additions & 17 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,27 +788,15 @@ impl Step for Clippy {
cargo.add_rustc_lib_path(builder, compiler);
let mut cargo = prepare_cargo_test(cargo, &[], &[], "clippy", compiler, host, builder);

// propagate --bless
if builder.config.cmd.bless() {
cargo.env("BLESS", "Gesundheit");
}

if builder.try_run(&mut cargo).is_ok() {
// The tests succeeded; nothing to do.
return;
}

if !builder.config.cmd.bless() {
crate::detail_exit_macro!(1);
}

let mut cargo = builder.cargo(compiler, Mode::ToolRustc, SourceType::InTree, host, "run");
cargo.arg("-p").arg("clippy_dev");
// clippy_dev gets confused if it can't find `clippy/Cargo.toml`
cargo.current_dir(&builder.src.join("src").join("tools").join("clippy"));
if builder.config.rust_optimize.is_release() {
cargo.env("PROFILE", "release");
} else {
cargo.env("PROFILE", "debug");
}
cargo.arg("--");
cargo.arg("bless");
builder.run(&mut cargo.into());
}
}

Expand Down
12 changes: 3 additions & 9 deletions src/tools/clippy/tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn base_config(test_dir: &str) -> compiletest::Config {
},
dependencies_crate_manifest_path: Some("clippy_test_deps/Cargo.toml".into()),
target: None,
out_dir: "target/ui_test".into(),
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap_or("target".into())).join("ui_test"),
..compiletest::Config::rustc(Path::new("tests").join(test_dir))
};

Expand Down Expand Up @@ -116,10 +116,7 @@ fn run_ui_toml() {

config.stderr_filter(
&regex::escape(
&std::path::Path::new(file!())
.parent()
.unwrap()
.canonicalize()
&fs::canonicalize("tests")
.unwrap()
.parent()
.unwrap()
Expand Down Expand Up @@ -175,10 +172,7 @@ fn run_ui_cargo() {

config.stderr_filter(
&regex::escape(
&std::path::Path::new(file!())
.parent()
.unwrap()
.canonicalize()
&fs::canonicalize("tests")
.unwrap()
.parent()
.unwrap()
Expand Down

0 comments on commit de69d55

Please sign in to comment.