-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·43 lines (34 loc) · 1.03 KB
/
test.sh
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
#!/bin/sh
set -e
SKIP_TEST="SKIP_TEST"
SCRIPT_DIR="$(CDPATH= command cd -- "$(dirname -- "$0")" && pwd -P)"
TEST_DIR="$SCRIPT_DIR/test-output"
echo "- Building executable"
go build
echo "- Running tests"
for example in examples/*; do
# Set up test directory for raw Y2K file exports
rm -rf "$TEST_DIR"
mkdir "$TEST_DIR"
# Skip tests that are contain the SKIP_TEST string.
# This is done for examples like "count-up-forever.y2k"
if grep -q $SKIP_TEST $example; then
continue
fi
# Evaluate the expected output of a Y2K example file
expected="$(./y2k $example 15)"
# Export the raw file to a set of empty timestamp files
./y2k -outdir $TEST_DIR -export $example >/dev/null
output="$(./y2k $TEST_DIR 15)"
# Check if both outputs are equal
if [ "$output" != "$expected" ]; then
echo "ERROR: $example"
echo "Expected: $expected"
echo "Output: $output"
exit 1
else
echo "OK: $example"
fi
done
echo "All tests passed"
rm -rf "$TEST_DIR"