Skip to content

Commit 6fbf6e2

Browse files
authored
ensure-stubs-compile: Deny all warnings except new_without_default (#1030)
We don't find it too useful to have students implement Default; in the context of these exercises it's just busywork. All other warnings in stubs have been dealt with, and we find it useful to ensure there are no further ones. Closes #659 This is appropriate because: * stubs and tests are now ensured to have no Clippy warnings or errors * examples are ensured to have no errors, and we're unconcerned about them having warnings since students don't see them * rustfmt is enforced
1 parent 1f15e78 commit 6fbf6e2

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

_test/ensure-stubs-compile.sh

+5-14
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,20 @@ for dir in $changed_exercises; do
3333
# In CI, we may have already compiled using the example solution.
3434
# So we want to touch the src/lib.rs in some way,
3535
# so that we surely recompile using the stub.
36-
if [ -n "$CLIPPY" ]; then
37-
# We don't deny warnings in clippy mode,
38-
# just because there are many we don't want to deal with right now.
39-
# So in clippy mode it's just a touch.
40-
touch "$dir/src/lib.rs"
41-
else
42-
# In non-clippy mode, we do want to compile without warnings.
43-
sed -i -e '1i #![deny(warnings)]' "$dir/src/lib.rs"
44-
fi
36+
# Since we also want to deny warnings, that will also serve as the touch.
37+
sed -i -e '1i #![deny(warnings)]' "$dir/src/lib.rs"
4538

4639
# Deny warnings in the tests that may result from compiling the stubs.
4740
# This helps avoid, for example, an overflowing literal warning
4841
# that could be caused by a stub with a type that is too small.
4942
sed -i -e '1i #![deny(warnings)]' $dir/tests/*.rs
5043

5144
if [ -n "$CLIPPY" ]; then
52-
if ! (cd $dir && cargo clippy --lib --tests --color always 2>clippy.log); then
45+
# We don't find it useful in general to have students implement Default,
46+
# since we're generally not going to test it.
47+
if ! (cd $dir && cargo clippy --lib --tests --color always -- --allow clippy::new_without_default 2>clippy.log); then
5348
cat $dir/clippy.log
5449
broken="$broken\n$exercise"
55-
elif grep -q warning $dir/clippy.log; then
56-
# Warnings will be outputted, but do not fail the build.
57-
echo "clippy $exercise WARN"
58-
cat $dir/clippy.log
5950
else
6051
# Just to show progress
6152
echo "clippy $exercise OK"

0 commit comments

Comments
 (0)