Skip to content

Commit a6ad3a3

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

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/testsuite/package.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,68 @@ src/lib.rs
11711171
.run();
11721172
}
11731173

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

0 commit comments

Comments
 (0)