2016-04-17 23:24:36 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-03-15 15:34:34 +00:00
|
|
|
declare -i TEST_RESULT=0
|
|
|
|
FAILED_EXERCISES=''
|
|
|
|
|
2016-02-23 03:29:13 +00:00
|
|
|
for example_file in exercises/**/*.example
|
|
|
|
do
|
|
|
|
exercise_dir=$(dirname $example_file)
|
|
|
|
exercise=$(basename $example_file .example)
|
|
|
|
mv "$exercise_dir/$exercise.elm" "$exercise_dir/$exercise.impl"
|
|
|
|
mv "$exercise_dir/$exercise.example" "$exercise_dir/$exercise.elm"
|
2016-02-27 17:45:34 +00:00
|
|
|
echo '-------------------------------------------------------'
|
|
|
|
echo "Testing $exercise"
|
2016-05-13 21:05:18 +00:00
|
|
|
|
2016-05-13 22:56:30 +00:00
|
|
|
elm-make $exercise_dir/*Tests.elm --yes --output build.js && node build.js
|
2016-03-19 18:51:58 +00:00
|
|
|
|
2016-03-15 15:34:34 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2016-03-19 18:51:58 +00:00
|
|
|
TEST_RESULT=1
|
|
|
|
FAILED_EXERCISES+="$exercise\n"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $WITH_FORMAT ]; then
|
|
|
|
elm-format $exercise_dir/*.elm --yes
|
2016-03-15 15:34:34 +00:00
|
|
|
fi
|
2016-03-19 18:51:58 +00:00
|
|
|
|
2016-02-23 03:29:13 +00:00
|
|
|
mv "$exercise_dir/$exercise.elm" "$exercise_dir/$exercise.example"
|
|
|
|
mv "$exercise_dir/$exercise.impl" "$exercise_dir/$exercise.elm"
|
|
|
|
done
|
2016-03-15 15:34:34 +00:00
|
|
|
|
|
|
|
if [ $TEST_RESULT -ne 0 ]; then
|
|
|
|
echo "The following exercises failed"
|
|
|
|
printf $FAILED_EXERCISES
|
|
|
|
exit $TEST_RESULT
|
|
|
|
fi
|
2016-03-19 18:51:58 +00:00
|
|
|
|
|
|
|
if [ $WITH_FORMAT ]; then
|
|
|
|
git diff --quiet --exit-code
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "*******************************************************************"
|
|
|
|
echo "*******************************************************************"
|
|
|
|
echo "**Git diff found - perhaps some of your changes are not formatted?*"
|
|
|
|
echo "** Please inspect the diffs before pushing. **"
|
|
|
|
echo "*******************************************************************"
|
|
|
|
echo "*******************************************************************"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|