Skip to content

Commit

Permalink
test: Verify that the vcs_info file gets packaged when allowing dirty.
Browse files Browse the repository at this point in the history
  • Loading branch information
torhovland committed May 24, 2024
1 parent fc15233 commit f7a0473
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,74 @@ src/lib.rs
.run();
}

#[cargo_test]
fn issue_13695_dirty_vcs_info() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2015"
description = "foo"
license = "foo"
documentation = "foo"
"#,
)
.file("src/lib.rs", "")
.build();

let repo = git::init(&p.root());
// Initial commit, with no files added.
git::commit(&repo);

// Fail because worktree is dirty.
p.cargo("package")
.with_status(101)
.with_stderr_contains(
"[ERROR] 2 files in the working directory contain changes that were not yet committed into git:",
)
.run();

// Listing fails too.
p.cargo("package --list")
.with_status(101)
.with_stderr_contains(
"[ERROR] 2 files in the working directory contain changes that were not yet committed into git:",
)
.run();

// Allowing a dirty worktree results in the vcs file being included.
p.cargo("package --allow-dirty").run();

let f = File::open(&p.root().join("target/package/foo-0.1.0.crate")).unwrap();
validate_crate_contents(
f,
"foo-0.1.0.crate",
&[
".cargo_vcs_info.json",
"Cargo.toml",
"Cargo.toml.orig",
"src/lib.rs",
],
&[],
);

// Listing provides a consistent result.
p.cargo("package --list --allow-dirty")
.with_stderr("")
.with_stdout(
"\
.cargo_vcs_info.json
Cargo.toml
Cargo.toml.orig
src/lib.rs
",
)
.run();
}

#[cargo_test]
fn generated_manifest() {
let registry = registry::alt_init();
Expand Down

0 comments on commit f7a0473

Please sign in to comment.