From 972d5346a20f93480a59f1a0649df9b0ccdc344b Mon Sep 17 00:00:00 2001 From: Jem Tucker Date: Sat, 10 Aug 2024 20:13:01 +0100 Subject: [PATCH 1/2] test: Add test for issue rust-lang#14379 --- tests/testsuite/build_script.rs | 35 ++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 04af014dae8..fbfc136d871 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -14,7 +14,7 @@ use cargo_test_support::tools; use cargo_test_support::{ basic_manifest, cargo_exe, cross_compile, is_coarse_mtime, project, project_in, }; -use cargo_test_support::{rustc_host, sleep_ms, slow_cpu_multiplier, symlink_supported}; +use cargo_test_support::{git, rustc_host, sleep_ms, slow_cpu_multiplier, symlink_supported}; use cargo_util::paths::{self, remove_dir_all}; #[cargo_test] @@ -5814,3 +5814,36 @@ fn links_overrides_with_target_applies_to_host() { "#]]) .run(); } + +#[cargo_test] +fn directory_with_leading_underscore() { + let p: cargo_test_support::Project = git::new("foo", |p| { + p.no_manifest() + .file( + "_foo/foo/Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2021" + build = "build.rs" + "#, + ) + .file("_foo/foo/src/main.rs", "fn main() {}") + .file("_foo/foo/build.rs", "fn main() { }") + }); + p.cargo("build --manifest-path=_foo/foo/Cargo.toml -v") + .with_status(101) + .with_stderr_data(r#"[ERROR] failed to determine package fingerprint for build script for foo v0.1.0 ([ROOT]/foo/_foo/foo) + +Caused by: + failed to determine the most recently modified file in [ROOT]/foo/_foo/foo + +Caused by: + failed to determine list of files in [ROOT]/foo/_foo/foo + +Caused by: + Unimplemented short keyword: '_' +"#) + .run(); +} From 978514251a1f75f54915796bf28f65443d0af001 Mon Sep 17 00:00:00 2001 From: Jem Tucker Date: Sat, 10 Aug 2024 20:21:40 +0100 Subject: [PATCH 2/2] fix: use longhand gitoxide path-spec patterns --- src/cargo/sources/path.rs | 4 ++-- tests/testsuite/build_script.rs | 13 +------------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 4159da35275..d4acb1d2095 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -610,11 +610,11 @@ fn list_files_gix( let pathspec = { // Include the package root. - let mut include = BString::from(":/"); + let mut include = BString::from(":(top)"); include.push_str(package_prefix.as_ref()); // Exclude the target directory. - let mut exclude = BString::from(":!/"); + let mut exclude = BString::from(":!(exclude,top)"); exclude.push_str(target_prefix.as_ref()); vec![include, exclude] diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index fbfc136d871..4cd3584bf13 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -5833,17 +5833,6 @@ fn directory_with_leading_underscore() { .file("_foo/foo/build.rs", "fn main() { }") }); p.cargo("build --manifest-path=_foo/foo/Cargo.toml -v") - .with_status(101) - .with_stderr_data(r#"[ERROR] failed to determine package fingerprint for build script for foo v0.1.0 ([ROOT]/foo/_foo/foo) - -Caused by: - failed to determine the most recently modified file in [ROOT]/foo/_foo/foo - -Caused by: - failed to determine list of files in [ROOT]/foo/_foo/foo - -Caused by: - Unimplemented short keyword: '_' -"#) + .with_status(0) .run(); }