[Pkg-rust-maintainers] debcargo now runs tests!

Ximin Luo infinity0 at debian.org
Tue Mar 19 02:43:00 GMT 2019


(This does not concern the upcoming Debian Stable release, which is frozen and will not contain this feature.)

Since a recent commit, debcargo git HEAD now generates d/tests/control to support running the tests as a post-install autopkgtest. This includes installing any necessary dev-dependencies. It requires dh-cargo 18 which is available now in unstable.

Example usage is here: https://salsa.debian.org/rust-team/debcargo-conf/tree/wip/autopkgtest and see the commit message for more details

We use the "skip-not-installable" flag to tell autopkgtest not to treat uninstallable dev-dependencies as a critical failure, since sometimes they require extra testing crates (bencher, quickcheck, etc) that we haven't yet packaged for Debian.

It generates a test for every individual feature (including --default and --no default-features) as well as --all-features. See the bottom of this email for an example output for clap.

The reason we generate so many individual tests, is that it turns out that quite a lot of crate tests in the rust ecosystem don't actually work. So, when using debcargo we can mark individual feature tests as "broken", whilst expecting others to pass. For example for the libc crate we need to do this:

[packages."lib+default"]
test_is_broken = true

[packages."lib+rustc-dep-of-std"]
test_is_broken = true

(For these features, and any feature that depends on these, debcargo will mark the corresponding autopkgtest as "flaky". This is a hack; it is the closest flag that autopkgtest supports, that means "do actually run this test but it'll probably fail".)

You can also bypass this autopkgtest stuff and run the cargo test directly by running e.g.:

$ /usr/share/cargo/bin/cargo-auto-test ryu 0.2.7 --all-targets --no-default-features

This runs the build in a tmpdir that gets automatically cleaned up afterwards. But here it's your responsibility to make sure all the dependencies and dev-dependencies are available beforehand.

Please help test this on your favourite crate!

X

Sample output for clap 2.32.0, unfortunately not runnable right now due to lack of rust-version-sync in Debian:

Test-Command: /usr/share/cargo/bin/cargo-auto-test clap 2.32.0 --all-targets --all-features
Depends: dh-cargo (>= 18), librust-lazy-static-1+default-dev, librust-regex-1+default-dev, librust-version-sync-0.5+default-dev, @
Restrictions: allow-stderr, skip-not-installable

Test-Command: /usr/share/cargo/bin/cargo-auto-test clap 2.32.0 --all-targets --no-default-features
Depends: dh-cargo (>= 18), librust-lazy-static-1+default-dev, librust-regex-1+default-dev, librust-version-sync-0.5+default-dev, librust-clap-dev
Restrictions: allow-stderr, skip-not-installable

Test-Command: /usr/share/cargo/bin/cargo-auto-test clap 2.32.0 --all-targets --features ansi_term
Depends: dh-cargo (>= 18), librust-lazy-static-1+default-dev, librust-regex-1+default-dev, librust-version-sync-0.5+default-dev, librust-clap+ansi-term-dev
Restrictions: allow-stderr, skip-not-installable

Test-Command: /usr/share/cargo/bin/cargo-auto-test clap 2.32.0 --all-targets --features atty
Depends: dh-cargo (>= 18), librust-lazy-static-1+default-dev, librust-regex-1+default-dev, librust-version-sync-0.5+default-dev, librust-clap+atty-dev
Restrictions: allow-stderr, skip-not-installable

[..] etc you get the idea [..]

Test-Command: /usr/share/cargo/bin/cargo-auto-test clap 2.32.0 --all-targets --features yaml
Depends: dh-cargo (>= 18), librust-lazy-static-1+default-dev, librust-regex-1+default-dev, librust-version-sync-0.5+default-dev, librust-clap+yaml-dev
Restrictions: allow-stderr, skip-not-installable

Test-Command: /usr/share/cargo/bin/cargo-auto-test clap 2.32.0 --all-targets --features yaml-rust
Depends: dh-cargo (>= 18), librust-lazy-static-1+default-dev, librust-regex-1+default-dev, librust-version-sync-0.5+default-dev, librust-clap+yaml-rust-dev
Restrictions: allow-stderr, skip-not-installable


-- 
GPG: ed25519/56034877E1F87C35
GPG: rsa4096/1318EFAC5FBBDBCE
https://github.com/infinity0/pubkeys.git



More information about the Pkg-rust-maintainers mailing list