-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
test
executable file
·64 lines (49 loc) · 1.71 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
# Synopsis:
# Test the track's exercises.
# Arguments:
# $1: exercise slug: only this exercise will be tested (optional)
# Examples:
# ./bin/test
# ./bin/test two-fer
exercise_slug_filter="$1"
exit_code=0
function test_exercise() {
exercise_dir="${1}"
exercise_slug=$(basename "${exercise_dir}")
example_file_key="${2}"
if [ -z "${exercise_slug_filter}" ] ||
[ "${exercise_slug}" == "${exercise_slug_filter}" ]; then
echo "Checking ${exercise_slug} exercise..."
pushd "${exercise_dir}" > /dev/null
solution_file=$(jq -r '.files.solution[0]' '.meta/config.json')
test_file=$(jq -r '.files.test[0]' '.meta/config.json')
example_file=$(jq -r ".files.${example_file_key}[0]" '.meta/config.json')
tmp_solution_file=$(mktemp --suffix '-solution.scala')
tmp_test_file=$(mktemp --suffix '-test.scala')
cp "${solution_file}" "${tmp_solution_file}"
cp "${test_file}" "${tmp_test_file}"
cp "${example_file}" "${solution_file}"
sed -i -e '/^\s*pending\s*$/d' "${test_file}"
sbt test
if [ $? -ne 0 ]; then
exit_code=1
fi
mv "${tmp_solution_file}" "${solution_file}"
mv "${tmp_test_file}" "${test_file}"
popd > /dev/null
fi
}
# Verify the Concept Exercises
for concept_exercise_dir in ./exercises/concept/*/; do
if [ -d $concept_exercise_dir ]; then
test_exercise "${concept_exercise_dir}" "exemplar"
fi
done
# Verify the Practice Exercises
for practice_exercise_dir in ./exercises/practice/*/; do
if [ -d $practice_exercise_dir ]; then
test_exercise "${practice_exercise_dir}" "example"
fi
done
exit $exit_code