Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7807,3 +7807,33 @@ fn publish_to_alt_registry_warns() {
"#]])
.run();
}

#[cargo_test]
fn package_dir_not_excluded_from_backups() {
// This test documents the current behavior where target directory is NOT excluded from backups.
// After the fix, this test will be updated to verify that CACHEDIR.TAG exists.
let p = project()
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for faster test execution (avoid to binary linking)

Suggested change
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
.file("src/lib.rs", "")

.build();

p.cargo("package --allow-dirty")
.with_stderr_data(str![[r#"
[WARNING] manifest has no description, license, license-file, documentation, homepage or repository
|
= [NOTE] see https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info
[PACKAGING] foo v0.0.1 ([ROOT]/foo)
[PACKAGED] 4 files, [FILE_SIZE]B ([FILE_SIZE]B compressed)
[VERIFYING] foo v0.0.1 ([ROOT]/foo)
[COMPILING] foo v0.0.1 ([ROOT]/foo/target/package/foo-0.0.1)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();

// Currently, CACHEDIR.TAG does NOT exist in target directory
let cachedir_tag = p.root().join("target/CACHEDIR.TAG");
assert!(
!cachedir_tag.exists(),
"CACHEDIR.TAG should not exist (documenting current buggy behavior)"
);
}