forked from miking-lang/miking-dppl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake
More file actions
executable file
·78 lines (72 loc) · 1.42 KB
/
make
File metadata and controls
executable file
·78 lines (72 loc) · 1.42 KB
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
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
testexec () {
set +e
output="$output$($1 2>&1)"
exit_code=$?
echo "$output"
if [ $exit_code -eq 0 ]
then
rm $1
else
echo "ERROR: compiled binary $1 exited with $exit_code"
rm $1
exit 1
fi
set -e
}
testmi () {
set +e
binary=$(mktemp)
compile_cmd="mi compile --test --disable-optimizations --output $binary"
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
testexec "$binary"
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"
model="$1"
# Add any remaining arguments to the compile command
shift 2
compile_cmd="$compile_cmd $*"
echo $compile_cmd
output=$model
compile_output=$($compile_cmd $model 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 $model 2>&1' exited with $exit_code"
exit 1
fi
set -e
output="$output "
testexec "$cpplout"
}
case $1 in
test)
testmi "$2"
;;
test-cppl)
testcppl "$2" "$3"
;;
test-cdppl)
testcppl "$2" "$3" --dppl-typecheck
;;
*)
>&2 echo "Incorrect argument"
exit 1
;;
esac