Skip to content

Commit 7407084

Browse files
committed
Merge pull request #107 from petertseng/warnings
travis: add a required build that fails on warnings
2 parents 4af72e9 + 285bb2a commit 7407084

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

.travis.yml

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ rust:
99
- stable
1010
- beta
1111
- nightly
12+
env:
13+
- DENYWARNINGS=
14+
- DENYWARNINGS=1
1215
matrix:
1316
allow_failures:
1417
- rust: nightly
18+
- rust: beta
19+
env: DENYWARNINGS=1

_test/check-exercises.sh

+24-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#!/bin/bash
22

3-
set -e
3+
# In DENYWARNINGS mode, do not set -e so that we run all tests.
4+
# This allows us to see all warnings.
5+
if [ -z "$DENYWARNINGS" ]; then
6+
set -e
7+
fi
8+
49
tmp=${TMPDIR:-/tmp/}
510
mkdir "${tmp}exercises"
611

12+
exitcode=0
13+
714
# An exercise worth testing is defined here as any top level directory with
815
# a 'tests' directory
916
for exercise in exercises/*/tests; do
@@ -26,15 +33,27 @@ for exercise in exercises/*/tests; do
2633
sed -i '/\[ignore\]/d' $test
2734
done
2835

29-
# Run the test and get the status
30-
cargo test
36+
if [ -n "$DENYWARNINGS" ]; then
37+
sed -i -e '1i #![deny(warnings)]' src/lib.rs
38+
39+
# No-run mode so we see no test output.
40+
# Quiet mode so we see no compile output
41+
# (such as "Compiling"/"Downloading").
42+
# Compiler errors will still be shown though.
43+
# Both flags are necessary to keep things quiet.
44+
cargo test --quiet --no-run
45+
else
46+
# Run the test and get the status
47+
cargo test
48+
fi
3149
)
3250

3351
status=$?
3452

3553
if [ $status -ne 0 ]
3654
then
37-
echo "Failed";
38-
return 1;
55+
exitcode=1
3956
fi
4057
done
58+
59+
exit $exitcode

0 commit comments

Comments
 (0)