From a4ad834a216bf1fc57445e2681ef1c35918f6c14 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 16 Apr 2016 04:43:56 -0700 Subject: [PATCH 1/4] travis: add an allowed-fail build that fails on warnings I don't intend to be terribly strict on warnings (so as to actually fail a build with them) but I think I'd like a way to see them, so I'll let Travis do the job. This is motivated by the fact that I introduced warnings in #81 and they were not caught. --- .travis.yml | 4 ++++ _test/check-exercises.sh | 5 +++++ 2 files changed, 9 insertions(+) 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..cdac70a2e 100755 --- a/_test/check-exercises.sh +++ b/_test/check-exercises.sh @@ -19,6 +19,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,6 +27,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 6511aacab9e2283965b1ffc2fc43569cea86fa4f Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 16 Apr 2016 05:07:20 -0700 Subject: [PATCH 2/4] 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 cdac70a2e..48266d927 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 @@ -39,7 +46,8 @@ for exercise in exercises/*/tests; do if [ $status -ne 0 ] then - echo "Failed"; - return 1; + exitcode=1 fi done + +exit $exitcode From 5177c6dacf30be554fe14bbf62c21c5ed4664096 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 16 Apr 2016 05:18:04 -0700 Subject: [PATCH 3/4] 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 48266d927..c7d8831ca 100755 --- a/_test/check-exercises.sh +++ b/_test/check-exercises.sh @@ -36,10 +36,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=$? From 1073819ee2bc548d6f980812cb9c4a93b8f93e31 Mon Sep 17 00:00:00 2001 From: Peter Tseng Date: Sat, 16 Apr 2016 05:19:59 -0700 Subject: [PATCH 4/4] DO NOT MERGE: introduce some warnings This tests whether multiple warnings are showing up. --- exercises/tournament/example.rs | 2 ++ exercises/word-count/example.rs | 2 ++ 2 files changed, 4 insertions(+) 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;