From 4a616ca64c3c979dcf2740ed2f3564664e3aaf80 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 16 Apr 2016 04:43:56 -0700 Subject: [PATCH 1/3] travis: add a required build that fails on warnings This is motivated by the fact that I introduced warnings in #81 and they were not caught. Definitely open to discussion on whether it should be required! I don't want this to be a nuisance, but I do generally like to avoid warnings. --- .travis.yml | 5 +++++ _test/check-exercises.sh | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3d1c012ce..a91d310fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,11 @@ rust: - stable - beta - nightly +env: + - DENYWARNINGS= + - DENYWARNINGS=1 matrix: allow_failures: - rust: nightly + - rust: beta + env: DENYWARNINGS=1 diff --git a/_test/check-exercises.sh b/_test/check-exercises.sh index d512652e0..088df6bbb 100755 --- a/_test/check-exercises.sh +++ b/_test/check-exercises.sh @@ -26,6 +26,10 @@ for exercise in exercises/*/tests; do sed -i '/\[ignore\]/d' $test done + if [ -n "$DENYWARNINGS" ]; then + sed -i -e '1i #![deny(warnings)]' src/lib.rs + fi + # Run the test and get the status cargo test ) From 4f42681fc78381507ad71c78b3b003e02f55e218 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 16 Apr 2016 05:07:20 -0700 Subject: [PATCH 2/3] check-exercises: Show all failures in DENYWARNINGS mode This requires not setting -e for the `cargo test` run, nor exiting early in the manual status check. The motivation is that we'd like to see all warnings in this mode, not just the first exercise with warnings. --- _test/check-exercises.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/_test/check-exercises.sh b/_test/check-exercises.sh index 088df6bbb..49f2201ed 100755 --- a/_test/check-exercises.sh +++ b/_test/check-exercises.sh @@ -1,9 +1,16 @@ #!/bin/bash -set -e +# In DENYWARNINGS mode, do not set -e so that we run all tests. +# This allows us to see all warnings. +if [ -z "$DENYWARNINGS" ]; then + set -e +fi + tmp=${TMPDIR:-/tmp/} mkdir "${tmp}exercises" +exitcode=0 + # An exercise worth testing is defined here as any top level directory with # a 'tests' directory for exercise in exercises/*/tests; do @@ -38,7 +45,8 @@ for exercise in exercises/*/tests; do if [ $status -ne 0 ] then - echo "Failed"; - return 1; + exitcode=1 fi done + +exit $exitcode From 285bb2a4243f2e568fb81cb1d41dc4c13023a66e Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 16 Apr 2016 05:18:04 -0700 Subject: [PATCH 3/3] check-exercises: Silence non-warning output in DENYWARNINGS mode In DENYWARNINGS I just want to see all the warnings; I don't care about whether the tests actually pass or what I'm compiling or downloading. --- _test/check-exercises.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/_test/check-exercises.sh b/_test/check-exercises.sh index 49f2201ed..949af96f2 100755 --- a/_test/check-exercises.sh +++ b/_test/check-exercises.sh @@ -35,10 +35,17 @@ for exercise in exercises/*/tests; do if [ -n "$DENYWARNINGS" ]; then sed -i -e '1i #![deny(warnings)]' src/lib.rs - fi - # Run the test and get the status - cargo test + # No-run mode so we see no test output. + # Quiet mode so we see no compile output + # (such as "Compiling"/"Downloading"). + # Compiler errors will still be shown though. + # Both flags are necessary to keep things quiet. + cargo test --quiet --no-run + else + # Run the test and get the status + cargo test + fi ) status=$?