forked from miking-lang/miking-dppl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make
executable file
·67 lines (62 loc) · 1.37 KB
/
make
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
65
66
67
#!/bin/sh
testmi () {
set +e
binary=$(mktemp)
compile_cmd="mi compile --test --disable-optimizations --output $binary"
[ -z "$output" ] && output="$1 "
compile_output=$($compile_cmd $1 2>&1)
exit_code=$?
[ -n "$compile_output" ] && output="$output\n$compile_output"
if [ $exit_code -eq 0 ]
then
output="$output$($binary 2>&1)"
exit_code=$?
echo "$output"
if [ $exit_code -eq 0 ]
then
rm $binary
else
echo "ERROR: compiled binary for $1 exited with $exit_code"
rm $binary
exit 1
fi
else
echo "$output"
echo "ERROR: command '$compile_cmd $1 2>&1' exited with $exit_code"
exit 1
fi
set -e
}
testcppl () {
set +e
cpplout=$(mktemp)
compile_cmd="$2 --seed 0 --test --output $cpplout --output-mc --skip-final"
output=$1
compile_output=$($compile_cmd $1 2>&1)
exit_code=$?
[ -n "$compile_output" ] && output="$output\n$compile_output"
if [ $exit_code -ne 0 ]
then
echo "$output"
echo "ERROR: command '$compile_cmd $1 2>&1' exited with $exit_code"
exit 1
fi
set -e
output="$output "
# TODO(dlunde,2023-06-26): "out.mc" hardcoded, add support for outputting to
# temporary file in cppl-mc.
testmi "$cpplout.mc"
rm "$cpplout.mc"
}
case $1 in
test)
testmi "$2"
;;
test-cppl)
testcppl "$2" "$3"
;;
*)
>&2 echo "Incorrect argument"
exit 1
;;
esac