Suppose I have a project structure like this:
Cargo.lock Cargo.toml src src/lib.rs tests tests/atest.rs
and I have a
Cargo.toml that looks like this:
[package] name = "my-problem" version = "0.1.0" edition = "2021" exclude = ["tests/*"] # <<< tests directory is excluded from packaging... [dependencies] [[test]] name = "atest" # <<< but my integration test has a deliberate entry
If I run
cargo package, I get this error:
❯ cargo package --allow-dirty warning: manifest has no description, license, license-file, documentation, homepage or repository. See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info. Packaging my-problem v0.1.0 (/Users/ken.swanson/test/my-problem) Verifying my-problem v0.1.0 (/Users/ken.swanson/test/my-problem) error: failed to verify package tarball Caused by: failed to parse manifest at `/Users/ken.swanson/test/my-problem/target/package/my-problem-0.1.0/Cargo.toml` Caused by: can't find `atest` test at `tests/atest.rs` or `tests/atest/main.rs`. Please specify test.path if you want to use a non-default path.
The problem seems to be the explicit
[[test]] target for
Cargo.toml; if that section is removed, then
cargo test, and
cargo package all work as expected; it's only when explicitly trying to specify the test that
Is there any way to tell Cargo not to check for the existence of a target (i.e.,
[[test]]) when packaging?
The reason I ask is that I'm publishing a new version of a crate with features, and we moved some of our tests behind those features, so I added
[[test]] entries to our
required-features entries to make those tests compile correctly. I suspect our answer will be to just remove the
tests directory from our list of excludes but I wanted to check for all options.