62 lines
1.2 KiB
Bash
Executable File
62 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
TEST_DIR=$(dirname $0)
|
|
SRC_DIR=$TEST_DIR/../src
|
|
|
|
TEST_SRC=$(fd '\.ethlang' $TEST_DIR)
|
|
|
|
count_total=0
|
|
count_succeeded=0
|
|
|
|
for test_file in $TEST_SRC
|
|
do
|
|
echo "- $(basename $test_file)"
|
|
set +e
|
|
output=$(deno run -A $SRC_DIR/main.ts $test_file --test)
|
|
status=$?
|
|
set -e
|
|
|
|
|
|
if [[ status -ne 0 ]]
|
|
then
|
|
echo "-- failed: exit code $status --"
|
|
fi
|
|
|
|
if [[ status -eq 0 ]]
|
|
then
|
|
if grep -q '// expect:' $test_file
|
|
then
|
|
expected=$(grep '// expect:' $test_file | sed -E 's/\/\/ expect: (.*?)/\1/g')
|
|
if [[ $output != $expected ]]
|
|
then
|
|
echo "-- failed: incorrect output --"
|
|
echo "-- expected --"
|
|
echo "$expected"
|
|
echo "-- actual --"
|
|
echo "$output"
|
|
status=1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
count_total=$(($count_total + 1))
|
|
if [[ status -eq 0 ]]
|
|
then
|
|
count_succeeded=$(($count_succeeded + 1))
|
|
else
|
|
echo "failed"
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ $count_succeeded -eq $count_total ]]
|
|
then
|
|
echo "=== all tests passed ($count_succeeded/$count_total passed) ==="
|
|
else
|
|
echo "=== tests failed ($count_succeeded/$count_total passed) ==="
|
|
fi
|
|
|
|
|