From fb3f04bc9cadec007fb871eeead13e08f7dc99ef Mon Sep 17 00:00:00 2001 From: ZapAnton Date: Thu, 9 Aug 2018 23:11:10 +0300 Subject: [PATCH 1/3] ensure-lib-src-rs-exist: Updated the script to check if the stub file is empty --- _test/ensure-lib-src-rs-exist.sh | 41 +++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/_test/ensure-lib-src-rs-exist.sh b/_test/ensure-lib-src-rs-exist.sh index cf6969658..a73e565da 100755 --- a/_test/ensure-lib-src-rs-exist.sh +++ b/_test/ensure-lib-src-rs-exist.sh @@ -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 - # 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" + 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 From fffeb5cc001023c26b64ecefc44fd9a7b08460d4 Mon Sep 17 00:00:00 2001 From: ZapAnton Date: Mon, 20 Aug 2018 08:55:54 +0300 Subject: [PATCH 2/3] ensure-lib-src-rs-exist: The script is now evoked via bash in the Travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From 3a1aea437aec03430f2a2b8ccc873464103a9322 Mon Sep 17 00:00:00 2001 From: ZapAnton Date: Wed, 22 Aug 2018 12:11:54 +0300 Subject: [PATCH 3/3] ensure-lib-src-rs-exist: Updated script for consistent indenting --- _test/ensure-lib-src-rs-exist.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/_test/ensure-lib-src-rs-exist.sh b/_test/ensure-lib-src-rs-exist.sh index a73e565da..b938cb0ac 100755 --- a/_test/ensure-lib-src-rs-exist.sh +++ b/_test/ensure-lib-src-rs-exist.sh @@ -15,18 +15,19 @@ IGNORED_EXERCISES=( ) 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" + 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 + fi done if [ -n "$missing" ]; then