Skip to content

Commit 0c02803

Browse files
committed
test: Verify that the vcs_info file is not included in package when allowing dirty.
1 parent a8d72c6 commit 0c02803

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/testsuite/package.rs

+62
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,68 @@ src/lib.rs
11691169
.run();
11701170
}
11711171

1172+
#[cargo_test]
1173+
fn issue_13695_dirty_vcs_info() {
1174+
let p = project()
1175+
.file(
1176+
"Cargo.toml",
1177+
r#"
1178+
[package]
1179+
name = "foo"
1180+
version = "0.1.0"
1181+
edition = "2015"
1182+
description = "foo"
1183+
license = "foo"
1184+
documentation = "foo"
1185+
"#,
1186+
)
1187+
.file("src/lib.rs", "")
1188+
.build();
1189+
1190+
let repo = git::init(&p.root());
1191+
// Initial commit, with no files added.
1192+
git::commit(&repo);
1193+
1194+
// Fail because worktree is dirty.
1195+
p.cargo("package")
1196+
.with_status(101)
1197+
.with_stderr_contains(
1198+
"[ERROR] 2 files in the working directory contain changes that were not yet committed into git:",
1199+
)
1200+
.run();
1201+
1202+
// Listing fails too.
1203+
p.cargo("package --list")
1204+
.with_status(101)
1205+
.with_stderr_contains(
1206+
"[ERROR] 2 files in the working directory contain changes that were not yet committed into git:",
1207+
)
1208+
.run();
1209+
1210+
// Allowing a dirty worktree results in the vcs file not being included.
1211+
p.cargo("package --allow-dirty").run();
1212+
1213+
let f = File::open(&p.root().join("target/package/foo-0.1.0.crate")).unwrap();
1214+
validate_crate_contents(
1215+
f,
1216+
"foo-0.1.0.crate",
1217+
&["Cargo.toml", "Cargo.toml.orig", "src/lib.rs"],
1218+
&[],
1219+
);
1220+
1221+
// Listing provides a consistent result.
1222+
p.cargo("package --list --allow-dirty")
1223+
.with_stderr("")
1224+
.with_stdout(
1225+
"\
1226+
Cargo.toml
1227+
Cargo.toml.orig
1228+
src/lib.rs
1229+
",
1230+
)
1231+
.run();
1232+
}
1233+
11721234
#[cargo_test]
11731235
fn generated_manifest() {
11741236
let registry = registry::alt_init();

0 commit comments

Comments
 (0)