Skip to content

DO NOT MERGE: warnings #109

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

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ rust:
- beta
- nightly
matrix:
include:
- rust: stable
env: DENYWARNINGS=1
allow_failures:
- env: DENYWARNINGS=1
- rust: nightly
30 changes: 25 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 @@ -19,22 +26,35 @@ 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
for test in tests/*.rs; 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
2 changes: 2 additions & 0 deletions exercises/tournament/example.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::convert::AsRef;

use std::cmp::Ordering::Equal;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
Expand Down
2 changes: 2 additions & 0 deletions exercises/word-count/example.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::convert::AsRef;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as luck would have it, this is not a warning. word_count has a legitimate use of as_ref. Doesn't matter, I've seen what I need to see.


use std::collections::HashMap;
use std::collections::hash_map::Entry;

Expand Down