ensure-lib-src-rs-exist: Updated the script to check if the stub file is empty
@@ -4,16 +4,45 @@ 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
+ 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"
+ 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
