forked from nitlang/nitutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.sh
More file actions
executable file
·56 lines (46 loc) · 788 Bytes
/
tests.sh
File metadata and controls
executable file
·56 lines (46 loc) · 788 Bytes
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
# Return the template source file associated to the input file ($1)
# If no template match, return the empty string.
function get_template()
{
input="$1"
for tmpl in `ls tests/*.nit | tac`; do
echo "$tmpl" >&2
./diff "$tmpl" "$input" || continue
echo "$tmpl"
return 0
done
echo ""
return 1
}
# Compile the input source-file ($1)
function compile()
{
input="$1"
nitc "$1" -o out.bin
}
# Run the compiled program
function run()
{
./out.bin
}
# Check the result
function check()
{
return 0
}
# Fully process a single input file ($1)
function process()
{
i="$1"
t=`get_template "$i"`
if [ -z "$t" ]; then
echo "$i: Error. no matching template found "
continue
fi
b=`basename "$t" .nit`
echo "$i -> $b"
compile "$1"
}
for i in "$@"; do
process "$i"
done