-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun_compiler_tests.sh
executable file
·52 lines (46 loc) · 1.27 KB
/
run_compiler_tests.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
44
45
46
47
48
49
50
51
52
#!/bin/bash
if [ "$1" == "release" ]; then
mode="--release"
else
mode=""
fi
cargo build ${mode}
if [ $? != 0 ]; then
echo "Failed to build the compiler"
exit 1
fi
triplet=$(cargo run ${mode} -- info --triplet 2> /dev/null)
if [ -z "${triplet}" ]; then
echo "Failed to determine the target triplet"
exit 1
fi
echo "Current target triplet: ${triplet}"
fail_count=0
success_count=0
fail_list=()
if ! cargo run ${mode} -- build-pkg -O -f -i testcode/package.toml > /tmp/compile_output.log; then
echo "*********************"
echo " Compile failed"
cat /tmp/compile_output.log
echo "---------------------"
exit 1
fi
for file in testcode/src/*.mhr; do
name=$(basename -s .mhr ${file})
echo "Testing ${name}"
testcode/build/${triplet}/${name}/${name}
test_ret_value=$?
test_expected_ret_value=$(head -n 1 $file | cut -b 6-)
if [ "$test_ret_value" -ne "$test_expected_ret_value" ]; then
fail_count=$((fail_count + 1))
fail_list+=( $name )
echo " Run failed, expected $test_expected_ret_value, got $test_ret_value"
else
success_count=$((success_count + 1))
echo " Run succeeded"
fi
done
echo "Tests:"
echo " fail: ${fail_count} (failed: ${fail_list[@]})"
echo " success: ${success_count}"
exit ${fail_count}