diff --git a/.travis.yml b/.travis.yml index cf2d82dcc3..7d6b299ac8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,4 +13,5 @@ script: - './test/rust/check-exercises.sh' - './test/python/check-exercises.py' - './test/erlang/check-exercises.sh' + - './test/scala/check-exercises.sh' - "! git grep ' $' -- \\*.rb | grep -v 'assignments/ruby/ocr-numbers/ocr-numbers_test.rb'" diff --git a/test/scala/check-exercises.sh b/test/scala/check-exercises.sh new file mode 100755 index 0000000000..6c641e2785 --- /dev/null +++ b/test/scala/check-exercises.sh @@ -0,0 +1,37 @@ +#!/bin/bash +set -e +tmp=${TMPDIR:-/tmp/} +check_assignment () { + testfile="$1" + testfilename=${testfile##*/} + assignmentdir=${testfile%/src/test/scala*} + workdir=$(mktemp -d "${tmp}${testfilename}.XXXXXXXXXX") + mkdir -p "${workdir}/src/main/scala" + mkdir -p "${workdir}/src/test/scala" + cp "${assignmentdir}/build.sbt" "${workdir}/build.sbt" + cp "${assignmentdir}/example.scala" "${workdir}/src/main/scala/" + grep -v '^\s\+pending' "${testfile}" > "${workdir}/src/test/scala/${testfilename}" + ( + cd "${workdir}" + sbt test + ) + status=$? + rm -rf "${workdir}" + return $status +} + +failures=() +for assignment in assignments/scala/*/src/test/scala/*.scala; do + (check_assignment "${assignment}") + if [ $? -ne 0 ]; then + echo "check failed" + failures=(${failures[@]} $assignment) + fi +done +if [ "${#failures[*]}" -eq "0" ]; then + echo "SUCCESS!" +else + output=$(printf ", %s" "${failures[@]}") + echo "FAILURES: ${output:2}" + exit 1 +fi