diff --git a/.travis.yml b/.travis.yml index 6904ffef6..0a0e6a008 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: rust script: - "./_test/check-exercises.sh" -- "sh ./_test/ensure-lib-src-rs-exist.sh" +- "bash ./_test/ensure-lib-src-rs-exist.sh" - "sh ./_test/ensure-stubs-compile.sh" - "sh ./_test/count-ignores.sh" - "./bin/fetch-configlet" diff --git a/_test/ensure-lib-src-rs-exist.sh b/_test/ensure-lib-src-rs-exist.sh index cf6969658..b938cb0ac 100755 --- a/_test/ensure-lib-src-rs-exist.sh +++ b/_test/ensure-lib-src-rs-exist.sh @@ -4,16 +4,46 @@ repo=$(cd "$(dirname "$0")/.." && pwd) missing="" +empty_stub="" + +check_status=0 + +IGNORED_EXERCISES=( + "two-fer" #deprecated + "nucleotide-codons" #deprecated + "hexadecimal" #deprecated +) + for dir in $repo/exercises/*/; do - exercise=$(basename "$dir") - if [ ! -f $dir/src/lib.rs ]; then - # https://github.com/exercism/rust/pull/270 - echo "$exercise is missing a src/lib.rs; please create one (an empty file is acceptable)" - missing="$missing\n$exercise" - fi + exercise=$(basename "$dir") + + if [ ! -f "$dir/src/lib.rs" ]; then + # https://github.com/exercism/rust/pull/270 + echo "$exercise is missing a src/lib.rs; please create one (an empty file is acceptable)" + missing="$missing\n$exercise" + else + #Check if the stub file is empty + if [ ! -s "$dir/src/lib.rs" ] || [ "$(cat "$dir/src/lib.rs")" == "" ] && [[ " ${IGNORED_EXERCISES[*]} " != *"$exercise"* ]]; then + echo "$exercise has src/lib.rs stub file, but it is empty." + empty_stub="$empty_stub\n$exercise" + fi + fi done if [ -n "$missing" ]; then - echo "Exercises missing src/lib.rs:$missing" - exit 1 + printf "\nExercises missing src/lib.rs:$missing\n" + + check_status=1 +fi + +if [ -n "$empty_stub" ]; then + printf "\nExercises with empty src/lib.rs stub file:$empty_stub\n" + + check_status=1 +fi + +if [ "$check_status" -ne 0 ]; then + exit 1 +else + exit 0 fi