diff --git a/.travis.yml b/.travis.yml index 3d1c012ce..2cdfe0c4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,5 +10,9 @@ rust: - beta - nightly matrix: + include: + - rust: stable + env: DENYWARNINGS=1 allow_failures: + - env: DENYWARNINGS=1 - rust: nightly diff --git a/_test/check-exercises.sh b/_test/check-exercises.sh index d512652e0..c7d8831ca 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 @@ -19,6 +26,7 @@ for exercise in exercises/*/tests; do ( cd $workdir [ -d src ] || mkdir src + cp example.rs src/lib.rs # Forcibly strip all "ignore" statements from the testing files @@ -26,15 +34,27 @@ for exercise in exercises/*/tests; do sed -i '/\[ignore\]/d' $test done - # Run the test and get the status - cargo test + if [ -n "$DENYWARNINGS" ]; then + sed -i -e '1i #![deny(warnings)]' src/lib.rs + + # 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=$? if [ $status -ne 0 ] then - echo "Failed"; - return 1; + exitcode=1 fi done + +exit $exitcode diff --git a/exercises/tournament/example.rs b/exercises/tournament/example.rs index 8d741007c..6359ce9c0 100644 --- a/exercises/tournament/example.rs +++ b/exercises/tournament/example.rs @@ -1,3 +1,5 @@ +use std::convert::AsRef; + use std::cmp::Ordering::Equal; use std::collections::HashMap; use std::collections::hash_map::Entry; diff --git a/exercises/word-count/example.rs b/exercises/word-count/example.rs index 787c8fc3e..6d555841e 100644 --- a/exercises/word-count/example.rs +++ b/exercises/word-count/example.rs @@ -1,3 +1,5 @@ +use std::convert::AsRef; + use std::collections::HashMap; use std::collections::hash_map::Entry;