Skip to content

Commit f4c97b2

Browse files
committed
test(package): Verify the no-manifest case
1 parent bbb6aff commit f4c97b2

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

tests/testsuite/package.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,3 +3041,59 @@ src/main.rs
30413041
&[],
30423042
);
30433043
}
3044+
#[cargo_test]
3045+
#[cfg(windows)] // windows is the platform that is most consistently configured for case insensitive filesystems
3046+
fn no_manifest_found() {
3047+
let p = project()
3048+
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
3049+
.file("src/bar.txt", "") // should be ignored when packaging
3050+
.build();
3051+
// Workaround `project()` making a `Cargo.toml` on our behalf
3052+
std::fs::remove_file(p.root().join("Cargo.toml")).unwrap();
3053+
std::fs::write(
3054+
p.root().join("CARGO.TOML"),
3055+
r#"
3056+
[package]
3057+
name = "foo"
3058+
version = "0.0.1"
3059+
authors = []
3060+
exclude = ["*.txt"]
3061+
license = "MIT"
3062+
description = "foo"
3063+
"#,
3064+
)
3065+
.unwrap();
3066+
3067+
p.cargo("package")
3068+
.with_stderr(
3069+
"\
3070+
[WARNING] manifest has no documentation[..]
3071+
See [..]
3072+
[PACKAGING] foo v0.0.1 ([CWD])
3073+
[VERIFYING] foo v0.0.1 ([CWD])
3074+
[COMPILING] foo v0.0.1 ([CWD][..])
3075+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
3076+
[PACKAGED] 3 files, [..] ([..] compressed)
3077+
",
3078+
)
3079+
.run();
3080+
assert!(p.root().join("target/package/foo-0.0.1.crate").is_file());
3081+
p.cargo("package -l")
3082+
.with_stdout(
3083+
"\
3084+
CARGO.TOML
3085+
Cargo.lock
3086+
src/main.rs
3087+
",
3088+
)
3089+
.run();
3090+
p.cargo("package").with_stdout("").run();
3091+
3092+
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
3093+
validate_crate_contents(
3094+
f,
3095+
"foo-0.0.1.crate",
3096+
&["CARGO.TOML", "Cargo.lock", "src/main.rs"],
3097+
&[],
3098+
);
3099+
}

0 commit comments

Comments
 (0)