Skip to content

Commit 871b17f

Browse files
committed
test(package): show behavior with core.symlinks=false
1 parent 8adbe0e commit 871b17f

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

tests/testsuite/package.rs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7025,3 +7025,85 @@ src/main.rs
70257025
"#]])
70267026
.run();
70277027
}
7028+
7029+
#[cargo_test]
7030+
fn git_core_symlinks_false() {
7031+
if !symlink_supported() {
7032+
return;
7033+
}
7034+
7035+
let git_project = git::new("bar", |p| {
7036+
p.file(
7037+
"Cargo.toml",
7038+
r#"
7039+
[package]
7040+
name = "bar"
7041+
description = "bar"
7042+
license = "MIT"
7043+
edition = "2021"
7044+
documentation = "foo"
7045+
"#,
7046+
)
7047+
.file("src/lib.rs", "//! This is a module")
7048+
.symlink("src/lib.rs", "symlink-lib.rs")
7049+
.symlink_dir("src", "symlink-dir")
7050+
});
7051+
7052+
let url = git_project.root().to_url().to_string();
7053+
7054+
let p = project().build();
7055+
let root = p.root();
7056+
// Remove the default project layout,
7057+
// so we can git-fetch from git_project under the same directory
7058+
fs::remove_dir_all(&root).unwrap();
7059+
fs::create_dir_all(&root).unwrap();
7060+
let repo = git::init(&root);
7061+
7062+
let mut cfg = repo.config().unwrap();
7063+
cfg.set_bool("core.symlinks", false).unwrap();
7064+
7065+
// let's fetch from git_project so it respects our core.symlinks=false config.
7066+
repo.remote_anonymous(&url)
7067+
.unwrap()
7068+
.fetch(&["HEAD"], None, None)
7069+
.unwrap();
7070+
let rev = repo
7071+
.find_reference("FETCH_HEAD")
7072+
.unwrap()
7073+
.peel_to_commit()
7074+
.unwrap();
7075+
repo.reset(rev.as_object(), git2::ResetType::Hard, None)
7076+
.unwrap();
7077+
7078+
p.cargo("package --allow-dirty")
7079+
.with_stderr_data(str![[r#"
7080+
[PACKAGING] bar v0.0.0 ([ROOT]/foo)
7081+
[PACKAGED] 7 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
7082+
[VERIFYING] bar v0.0.0 ([ROOT]/foo)
7083+
[COMPILING] bar v0.0.0 ([ROOT]/foo/target/package/bar-0.0.0)
7084+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
7085+
7086+
"#]])
7087+
.run();
7088+
7089+
let f = File::open(&p.root().join("target/package/bar-0.0.0.crate")).unwrap();
7090+
validate_crate_contents(
7091+
f,
7092+
"bar-0.0.0.crate",
7093+
&[
7094+
"Cargo.lock",
7095+
"Cargo.toml",
7096+
"Cargo.toml.orig",
7097+
"src/lib.rs",
7098+
// We're missing symlink-dir/lib.rs in the `.crate` file.
7099+
"symlink-dir",
7100+
"symlink-lib.rs",
7101+
".cargo_vcs_info.json",
7102+
],
7103+
[
7104+
// And their contents are incorrect.
7105+
("symlink-dir", str!["[ROOT]/bar/src"]),
7106+
("symlink-lib.rs", str!["[ROOT]/bar/src/lib.rs"]),
7107+
],
7108+
);
7109+
}

0 commit comments

Comments
 (0)