]> git.proxmox.com Git - dh-cargo.git/commitdiff
cargo-auto-test: ignore some false positive test failures
authorXimin Luo <infinity0@debian.org>
Tue, 7 Jan 2020 11:13:31 +0000 (11:13 +0000)
committerXimin Luo <infinity0@debian.org>
Tue, 7 Jan 2020 12:59:25 +0000 (12:59 +0000)
cargo-auto-test
debian/changelog

index 0777f70613c9a375d46c1a22ecf575a503ca5136..041c913af72e273d746938a48b29954d6028eb03 100755 (executable)
@@ -3,6 +3,9 @@
 #
 # Requires dev-dependencies to be installed. If you give extra flags such as
 # "--all-features", then these features' dependencies must also be installed.
+#
+# This script also swallows some known false-positive test failures, so you
+# don't have to set test_is_broken everywhere in your debcargo.toml configs.
 
 set -e
 
@@ -45,5 +48,38 @@ export PATH="/usr/share/cargo/bin:$PATH"
 
 # run the test!
 
+if [ -t 2 ]; then flags="--color=always"; export RUSTDOCFLAGS="--color=always"; fi
+
+run_test() {
+       local n="$1"
+       shift
+       { cargo test $flags "$@" 2>&1; echo "$?" > "$rundir/run-$n.ec"; } | tee "$rundir/run-$n.log"
+       sed -i -e 's/\x1b\[[0-9;]*m//g' "$rundir/run-$n.log" # rm ansi colour codes
+       local x="$(< "$rundir/run-$n.ec")"
+       if [ "$x" = "0" ]; then
+               return 0
+       fi
+       local e="$(egrep -o '^error\[E[0-9]+\]' "$rundir/run-$n.log" | sort -u | tr '\n' ',')"
+       # some crates like to update their old versions to depend on their new
+       # versions, e.g. rand-core. unfortunately this breaks cargo test, see
+       # https://github.com/rust-lang/cargo/issues/6819. so just ignore them.
+       if [ "$e" = "error[E0463],error[E0465]," ]; then
+               echo "cargo-auto-test: ignore test failure due to upstream #6819: $e"
+               return 0
+       fi
+       return "$x"
+}
+
+set +e
+
 cargo prepare-debian "$rundir/registry" --link-from-system
-cargo test "$@"
+
+run_test 0 "$@"
+x="$?"
+if [ "$x" = "0" ]; then exit 0; fi
+if ! egrep -q '^error\[E0554\]' "$rundir/run-0.log"; then exit "$x"; fi
+
+echo
+echo "----------------------------------------------------------------"
+echo "cargo-auto-test: re-running test with RUSTC_BOOTSTRAP due to E0554"
+RUSTC_BOOTSTRAP=1 run_test 1 "$@"
index 0146578c107c5a014cd59651fc40ac1127d6e982..a3325c6de7f5c2e1f9e1aff0adaf07844c2d0e9c 100644 (file)
@@ -1,3 +1,9 @@
+dh-cargo (23) UNRELEASED; urgency=medium
+
+  * cargo-auto-test: ignore some false positive test failures
+
+ -- Ximin Luo <infinity0@debian.org>  Tue, 07 Jan 2020 11:13:02 +0000
+
 dh-cargo (22) unstable; urgency=medium
 
   * Drop DEB_CARGO_PACKAGE in favour of DESTDIR. (Closes: #946616)