From 9f07c83417f9c7bd2fec56b909dab1cafb8cc60a Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Wed, 4 Mar 2020 18:12:21 +0800 Subject: [PATCH] Don't create hardlink for library test, integrations tests and benches, fixing #7960 --- src/cargo/core/compiler/context/compilation_files.rs | 11 ++++++++--- tests/testsuite/bench.rs | 4 ++-- tests/testsuite/test.rs | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/cargo/core/compiler/context/compilation_files.rs b/src/cargo/core/compiler/context/compilation_files.rs index a9d6eb2861d..515ebb274fe 100644 --- a/src/cargo/core/compiler/context/compilation_files.rs +++ b/src/cargo/core/compiler/context/compilation_files.rs @@ -421,9 +421,14 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> { Some(types) => { for file_type in types { let path = out_dir.join(file_type.filename(&file_stem)); - let hardlink = link_stem - .as_ref() - .map(|&(ref ld, ref ls)| ld.join(file_type.filename(ls))); + // Don't create hardlink for tests + let hardlink = if unit.mode.is_any_test() { + None + } else { + link_stem + .as_ref() + .map(|&(ref ld, ref ls)| ld.join(file_type.filename(ls))) + }; let export_path = if unit.target.is_custom_build() { None } else { diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 9e03871ab3e..13d68a9936b 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -1612,9 +1612,9 @@ fn json_artifact_includes_executable_for_benchmark() { .with_json( r#" { - "executable": "[..]/foo/target/release/benchmark-[..][EXE]", + "executable": "[..]/foo/target/release/deps/benchmark-[..][EXE]", "features": [], - "filenames": [ "[..]/foo/target/release/benchmark-[..][EXE]" ], + "filenames": [ "[..]/foo/target/release/deps/benchmark-[..][EXE]" ], "fresh": false, "package_id": "foo 0.0.1 ([..])", "profile": "{...}", diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 9400f8d5e5d..7fe5665e049 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -3379,7 +3379,7 @@ fn json_artifact_includes_executable_for_library_tests() { .with_json( r#" { - "executable": "[..]/foo/target/debug/foo-[..][EXE]", + "executable": "[..]/foo/target/debug/deps/foo-[..][EXE]", "features": [], "filenames": "{...}", "fresh": false, @@ -3413,7 +3413,7 @@ fn json_artifact_includes_executable_for_integration_tests() { .with_json( r#" { - "executable": "[..]/foo/target/debug/integration_test-[..][EXE]", + "executable": "[..]/foo/target/debug/deps/integration_test-[..][EXE]", "features": [], "filenames": "{...}", "fresh": false,