Skip to content

travis: add a required build that fails on warnings #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ rust:
- stable
- beta
- nightly
env:
- DENYWARNINGS=
- DENYWARNINGS=1
matrix:
allow_failures:
- rust: nightly
- rust: beta
env: DENYWARNINGS=1
29 changes: 24 additions & 5 deletions _test/check-exercises.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,15 +33,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