elm/bin/build.sh

64 lines
1.9 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
2016-08-26 07:59:03 +00:00
# FORMAT
echo '-------------------------------------------------------'
echo "Checking Formatting"
if [ ! -f "bin/elm-format" ] || [[ ! $(bin/elm-format --help | grep "elm-format-0.18 0.6.1-alpha") ]]; then
echo "Installing local copy of elm-format"
bin/install-elm-format
2016-08-26 07:59:03 +00:00
fi
bin/elm-format --yes --validate exercises/**/*.example.elm exercises/**/tests/Tests.elm
2016-08-26 07:59:03 +00:00
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!"
2016-08-26 07:59:03 +00:00
fi
# TEST
declare -i TEST_RESULT=0
FAILED_EXERCISES=''
mkdir -p build/tests
for example_file in exercises/**/*.example.elm
do
2017-05-27 18:44:01 +00:00
# clean up generated code from last run
rm -rf build/tests/elm-stuff/generated-code/
2017-05-27 18:44:01 +00:00
exercise_dir=$(dirname $example_file)
exercise_name=$(basename $example_file .example.elm)
cp "$exercise_dir/$exercise_name.example.elm" "build/$exercise_name.elm"
cp "$exercise_dir/tests/elm-package.json" build/tests/
cat "$exercise_dir/tests/Tests.elm" | sed 's/skip <|//g' > build/tests/Tests.elm
2016-02-27 17:45:34 +00:00
echo '-------------------------------------------------------'
echo "Testing $exercise_name"
2016-05-13 21:05:18 +00:00
2017-05-27 18:44:01 +00:00
npm test -- build/tests/Tests.elm
# capture result from last command (elm-test)
if [ $? -ne 0 ]; then
TEST_RESULT=1
FAILED_EXERCISES+="$exercise_name\n"
fi
done
if [ $TEST_RESULT -ne 0 ]; then
echo "The following exercises failed"
printf $FAILED_EXERCISES
exit $TEST_RESULT
fi