Skip to content

Commit

Permalink
Add scala tests to travis
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrif committed Nov 13, 2013
1 parent 88643b2 commit 0369b59
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
37 changes: 37 additions & 0 deletions test/scala/check-exercises.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0369b59

Please sign in to comment.