diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c98d047dccd..c280cf8ba6c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -38,4 +38,5 @@ jobs: - name: Build and Test env: RUSTFLAGS: -D warnings + CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT: true run: cargo run --manifest-path ci/Cargo.toml build-and-test diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index b5fb69c7bc7..4548a6bfab2 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -34,4 +34,5 @@ jobs: - name: Build and Test env: RUSTFLAGS: -D warnings + CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT: true run: cargo run --manifest-path ci/Cargo.toml build-and-test diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b58465a117e..b945e7e635a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -60,4 +60,5 @@ jobs: - name: Build and Test env: RUSTFLAGS: -D warnings + CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT: true run: cargo run --manifest-path ci/Cargo.toml build-and-test diff --git a/src/test/mod.rs b/src/test/mod.rs index d680f6730ae..20193df5a7c 100644 --- a/src/test/mod.rs +++ b/src/test/mod.rs @@ -1130,8 +1130,23 @@ fn rustfmt() -> PathBuf { let mut me = env::current_exe().expect("failed to get current executable"); // Chop of the test name. me.pop(); - // Chop off `deps`. - me.pop(); + + // Handle Cargo's old and new filesystem layouts + // * v1: `target//deps/test-bin-[HASH][EXE]` + // * v2: `target//build//[HASH]/out/test-bin-[HASH][EXE]` + if me.ends_with("deps") { + // Chop off `deps`. + me.pop(); + } else if me.ends_with("out") { + // Chop off `out`. + me.pop(); + // Chop off ``. + me.pop(); + // Chop off ``. + me.pop(); + // Chop off `build`. + me.pop(); + } me.push("rustfmt"); assert!( diff --git a/tests/cargo-fmt/main.rs b/tests/cargo-fmt/main.rs index dcdbca07a77..63cc12521a8 100644 --- a/tests/cargo-fmt/main.rs +++ b/tests/cargo-fmt/main.rs @@ -10,8 +10,17 @@ use rustfmt_config_proc_macro::rustfmt_only_ci_test; fn cargo_fmt(args: &[&str]) -> (String, String) { let mut bin_dir = env::current_exe().unwrap(); bin_dir.pop(); // chop off test exe name + + // Handle Cargo's old and new filesystem layouts + // * v1: `target//deps/test-bin-[HASH][EXE]` + // * v2: `target//build//[HASH]/out/test-bin-[HASH][EXE]` if bin_dir.ends_with("deps") { bin_dir.pop(); + } else if bin_dir.ends_with("out") { + bin_dir.pop(); // chop off `out` + bin_dir.pop(); // chop off `` + bin_dir.pop(); // chop off `` + bin_dir.pop(); // chop off `build` } let cmd = bin_dir.join(format!("cargo-fmt{}", env::consts::EXE_SUFFIX));