From 9d06c41c6e69e25a68639a09b22baa7de3299fa9 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 31 May 2018 17:15:57 -0700 Subject: [PATCH 1/2] Make sure that the test_rust.sh script fails when a test fails Exit codes from find(1) seem not to be so reliable as we had hoped. Closes ticket 26258; bugfix on 0.3.3.4-alpha when we fixed #25560 --- changes/bug26258_033 | 4 ++++ src/test/test_rust.sh | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 changes/bug26258_033 diff --git a/changes/bug26258_033 b/changes/bug26258_033 new file mode 100644 index 0000000000..ceca383335 --- /dev/null +++ b/changes/bug26258_033 @@ -0,0 +1,4 @@ + o Major bugfixes (rust, testing): + - Fix a bug where a failure in the rust unit tests would not actually + cause the build to fail. Fixes bug 26258; bugfix on 0.3.3.4-alpha. + diff --git a/src/test/test_rust.sh b/src/test/test_rust.sh index d87336e700..854582ec17 100755 --- a/src/test/test_rust.sh +++ b/src/test/test_rust.sh @@ -3,13 +3,14 @@ set -e -CARGO_TARGET_DIR="${abs_top_builddir:-../../..}/src/rust/target" \ + +for cargo_toml in "${abs_top_srcdir:-../../..}"/src/rust/*/Cargo.toml; do + CARGO_TARGET_DIR="${abs_top_builddir:-../../..}/src/rust/target" \ CARGO_HOME="${abs_top_builddir:-../../..}/src/rust" \ - find "${abs_top_srcdir:-../../..}/src/rust" \ - -mindepth 2 -maxdepth 2 \ - -type f -name 'Cargo.toml' \ - -exec "${CARGO:-cargo}" test --all-features ${CARGO_ONLINE-"--frozen"} \ - --manifest-path '{}' \; + "${CARGO:-cargo}" test --all-features ${CARGO_ONLINE-"--frozen"} \ + --manifest-path "$cargo_toml" || exitcode=1 +done + +exit $exitcode -exit $? From ee860b8f37707cf60daae21b806d4d473daaf2d2 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 13 Jun 2018 12:21:25 -0400 Subject: [PATCH 2/2] squash! Make sure that the test_rust.sh script fails when a test fails Also make sure that we're actually running the test from within the right cwd, like we do when we're building. This seems necessary to avoid an error when running offline. Amusingly, it appears that we had this bug before: we just weren't noticing it, because of bug 26258. --- src/test/include.am | 1 + src/test/test_rust.sh | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/test/include.am b/src/test/include.am index b768f74475..cc4f3e5c88 100644 --- a/src/test/include.am +++ b/src/test/include.am @@ -9,6 +9,7 @@ TESTS_ENVIRONMENT = \ export builddir="$(builddir)"; \ export TESTING_TOR_BINARY="$(TESTING_TOR_BINARY)"; \ export CARGO="$(CARGO)"; \ + export EXTRA_CARGO_OPTIONS="$(EXTRA_CARGO_OPTIONS)"; \ export CARGO_ONLINE="$(CARGO_ONLINE)"; TESTSCRIPTS = \ diff --git a/src/test/test_rust.sh b/src/test/test_rust.sh index 854582ec17..8e8d29b895 100755 --- a/src/test/test_rust.sh +++ b/src/test/test_rust.sh @@ -4,11 +4,15 @@ set -e -for cargo_toml in "${abs_top_srcdir:-../../..}"/src/rust/*/Cargo.toml; do - CARGO_TARGET_DIR="${abs_top_builddir:-../../..}/src/rust/target" \ - CARGO_HOME="${abs_top_builddir:-../../..}/src/rust" \ - "${CARGO:-cargo}" test --all-features ${CARGO_ONLINE-"--frozen"} \ - --manifest-path "$cargo_toml" || exitcode=1 +for cargo_toml_dir in "${abs_top_srcdir:-../../..}"/src/rust/*; do + if [ -e "${cargo_toml_dir}/Cargo.toml" ]; then + cd "${cargo_toml_dir}" && \ + CARGO_TARGET_DIR="${abs_top_builddir:-../../..}/src/rust/target" \ + CARGO_HOME="${abs_top_builddir:-../../..}/src/rust" \ + "${CARGO:-cargo}" test --all-features ${CARGO_ONLINE:-"--frozen"} \ + ${EXTRA_CARGO_OPTIONS} \ + --manifest-path "${cargo_toml_dir}/Cargo.toml" || exitcode=1 + fi done exit $exitcode