mirror of
https://github.com/rust-lang/cargo
synced 2024-09-13 21:11:44 +00:00
test(package): Show different crate discovery cases
I left off the explicit `path` cases because I hope that will become moot
This commit is contained in:
parent
340050e0cb
commit
0cf29c5713
|
@ -3755,3 +3755,827 @@ path = "benches/bench_foo.rs"
|
|||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_inferred_build_rs_included() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/lib.rs", "build.rs"]
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("build.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 4 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&["Cargo.toml", "Cargo.toml.orig", "src/lib.rs", "build.rs"],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
include = [
|
||||
"src/lib.rs",
|
||||
"build.rs",
|
||||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_inferred_build_rs_excluded() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/lib.rs"]
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("build.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 3 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&["Cargo.toml", "Cargo.toml.orig", "src/lib.rs"],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
include = ["src/lib.rs"]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_explicit_build_rs_included() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/lib.rs", "build.rs"]
|
||||
build = "build.rs"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("build.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 4 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&["Cargo.toml", "Cargo.toml.orig", "src/lib.rs", "build.rs"],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
build = "build.rs"
|
||||
include = [
|
||||
"src/lib.rs",
|
||||
"build.rs",
|
||||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_explicit_build_rs_excluded() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/lib.rs"]
|
||||
build = "build.rs"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("build.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_status(101)
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[ERROR] couldn't read build.rs: [..]
|
||||
|
||||
[ERROR] could not compile `foo` (build script) due to 1 previous error
|
||||
[ERROR] failed to verify package tarball
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_inferred_lib_included() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/main.rs", "src/lib.rs"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 5 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&[
|
||||
"Cargo.lock",
|
||||
"Cargo.toml",
|
||||
"Cargo.toml.orig",
|
||||
"src/main.rs",
|
||||
"src/lib.rs",
|
||||
],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
include = [
|
||||
"src/main.rs",
|
||||
"src/lib.rs",
|
||||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_inferred_lib_excluded() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/main.rs"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 4 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/main.rs"],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
include = ["src/main.rs"]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_explicit_lib_included() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/main.rs", "src/lib.rs"]
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 5 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&[
|
||||
"Cargo.lock",
|
||||
"Cargo.toml",
|
||||
"Cargo.toml.orig",
|
||||
"src/main.rs",
|
||||
"src/lib.rs",
|
||||
],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
include = [
|
||||
"src/main.rs",
|
||||
"src/lib.rs",
|
||||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_explicit_lib_excluded() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/main.rs"]
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_status(101)
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[ERROR] couldn't read src/lib.rs: [..]
|
||||
|
||||
[ERROR] could not compile `foo` (lib) due to 1 previous error
|
||||
[ERROR] failed to verify package tarball
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_inferred_other_included() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/lib.rs", "src/bin/foo/main.rs", "examples/example_foo.rs", "tests/test_foo.rs", "benches/bench_foo.rs"]
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/foo/main.rs", "fn main() {}")
|
||||
.file("examples/example_foo.rs", "fn main() {}")
|
||||
.file("tests/test_foo.rs", "fn main() {}")
|
||||
.file("benches/bench_foo.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 8 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&[
|
||||
"Cargo.lock",
|
||||
"Cargo.toml",
|
||||
"Cargo.toml.orig",
|
||||
"src/lib.rs",
|
||||
"src/bin/foo/main.rs",
|
||||
"examples/example_foo.rs",
|
||||
"tests/test_foo.rs",
|
||||
"benches/bench_foo.rs",
|
||||
],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
include = [
|
||||
"src/lib.rs",
|
||||
"src/bin/foo/main.rs",
|
||||
"examples/example_foo.rs",
|
||||
"tests/test_foo.rs",
|
||||
"benches/bench_foo.rs",
|
||||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_inferred_other_excluded() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/lib.rs"]
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/foo/main.rs", "fn main() {}")
|
||||
.file("examples/example_foo.rs", "fn main() {}")
|
||||
.file("tests/test_foo.rs", "fn main() {}")
|
||||
.file("benches/bench_foo.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 4 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&["Cargo.lock", "Cargo.toml", "Cargo.toml.orig", "src/lib.rs"],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
include = ["src/lib.rs"]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_explicit_other_included() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/lib.rs", "src/bin/foo/main.rs", "examples/example_foo.rs", "tests/test_foo.rs", "benches/bench_foo.rs"]
|
||||
|
||||
[[bin]]
|
||||
name = "foo"
|
||||
|
||||
[[example]]
|
||||
name = "example_foo"
|
||||
|
||||
[[test]]
|
||||
name = "test_foo"
|
||||
|
||||
[[bench]]
|
||||
name = "bench_foo"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/foo/main.rs", "fn main() {}")
|
||||
.file("examples/example_foo.rs", "fn main() {}")
|
||||
.file("tests/test_foo.rs", "fn main() {}")
|
||||
.file("benches/bench_foo.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[COMPILING] foo v0.0.1 ([CWD][..])
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
|
||||
[PACKAGED] 8 files, [..] ([..] compressed)
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
||||
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
|
||||
validate_crate_contents(
|
||||
f,
|
||||
"foo-0.0.1.crate",
|
||||
&[
|
||||
"Cargo.lock",
|
||||
"Cargo.toml",
|
||||
"Cargo.toml.orig",
|
||||
"src/lib.rs",
|
||||
"src/bin/foo/main.rs",
|
||||
"examples/example_foo.rs",
|
||||
"tests/test_foo.rs",
|
||||
"benches/bench_foo.rs",
|
||||
],
|
||||
&[(
|
||||
"Cargo.toml",
|
||||
r#"# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
||||
#
|
||||
# When uploading crates to the registry Cargo will automatically
|
||||
# "normalize" Cargo.toml files for maximal compatibility
|
||||
# with all versions of Cargo and also rewrite `path` dependencies
|
||||
# to registry (e.g., crates.io) dependencies.
|
||||
#
|
||||
# If you are reading this file be aware that the original Cargo.toml
|
||||
# will likely look very different (and much more reasonable).
|
||||
# See Cargo.toml.orig for the original contents.
|
||||
|
||||
[package]
|
||||
edition = "2015"
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
include = [
|
||||
"src/lib.rs",
|
||||
"src/bin/foo/main.rs",
|
||||
"examples/example_foo.rs",
|
||||
"tests/test_foo.rs",
|
||||
"benches/bench_foo.rs",
|
||||
]
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
license = "MIT"
|
||||
|
||||
[[bin]]
|
||||
name = "foo"
|
||||
|
||||
[[example]]
|
||||
name = "example_foo"
|
||||
|
||||
[[test]]
|
||||
name = "test_foo"
|
||||
|
||||
[[bench]]
|
||||
name = "bench_foo"
|
||||
"#,
|
||||
)],
|
||||
);
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn discovery_explicit_other_excluded() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
edition = "2015"
|
||||
license = "MIT"
|
||||
description = "foo"
|
||||
documentation = "docs.rs/foo"
|
||||
authors = []
|
||||
include = ["src/lib.rs"]
|
||||
|
||||
[[main]]
|
||||
name = "foo"
|
||||
|
||||
[[example]]
|
||||
name = "example_foo"
|
||||
|
||||
[[test]]
|
||||
name = "test_foo"
|
||||
|
||||
[[bench]]
|
||||
name = "bench_foo"
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.file("src/bin/foo/main.rs", "fn main() {}")
|
||||
.file("examples/example_foo.rs", "fn main() {}")
|
||||
.file("tests/test_foo.rs", "fn main() {}")
|
||||
.file("benches/bench_foo.rs", "fn main() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("package")
|
||||
.with_status(101)
|
||||
.with_stdout("")
|
||||
.with_stderr(
|
||||
"\
|
||||
[PACKAGING] foo v0.0.1 ([CWD])
|
||||
[VERIFYING] foo v0.0.1 ([CWD])
|
||||
[ERROR] failed to verify package tarball
|
||||
|
||||
Caused by:
|
||||
failed to parse manifest at `[CWD]/target/package/foo-0.0.1/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
can't find `example_foo` example at `examples/example_foo.rs` or `examples/example_foo/main.rs`. Please specify example.path if you want to use a non-default path.
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue