2016-04-17 23:24:36 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-08-26 07:59:03 +00:00
|
|
|
# FORMAT
|
|
|
|
|
|
|
|
echo '-------------------------------------------------------'
|
|
|
|
echo "Checking Formatting"
|
|
|
|
|
|
|
|
which elm-format > /dev/null
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "elm-format not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
elm-format --yes --validate exercises/**/*{.example,Tests.elm}
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "*******************************************************************"
|
|
|
|
echo "*******************************************************************"
|
|
|
|
echo "** elm-format failed **"
|
|
|
|
echo "** perhaps some of your changes are not formatted? **"
|
|
|
|
echo "** Please run elm-format before pushing. **"
|
|
|
|
echo "*******************************************************************"
|
|
|
|
echo "*******************************************************************"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "formatting looks good!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# TEST
|
|
|
|
|
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-08-23 00:31:41 +00:00
|
|
|
# prevent elm-test from installing dependencies
|
|
|
|
mv $exercise_dir/elm-package.json $exercise_dir/elm-package.json.disabled
|
|
|
|
|
2016-08-17 11:14:17 +00:00
|
|
|
elm-test $exercise_dir/*Tests.elm
|
2016-03-19 18:51:58 +00:00
|
|
|
|
2016-08-23 00:31:41 +00:00
|
|
|
# capture result from last command (elm-test)
|
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
|
|
|
|
|
2016-08-23 00:31:41 +00:00
|
|
|
# be kind, rewind
|
|
|
|
mv $exercise_dir/elm-package.json.disabled $exercise_dir/elm-package.json
|
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
|