342
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
#!/bin/bash
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
# to make the script fail safely
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
set -euo pipefail
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
out=${1:-output}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
# compilation tests
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
function scala_compile {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
(ulimit -t 60; JAVA_OPTS="-Xmx1g" scala -Xprint:parser "$1" 2> ptmp 1> ptmp)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
# purity test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
function scala_vars {
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
(egrep '\bvar\b|\breturn\b|\.par\.|\.par |ListBuffer|mutable|new Array' ptmp 2> /dev/null 1> /dev/null)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
}
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
### compilation test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
echo "collatz.scala runs?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
if (scala_compile collatz.scala)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
27 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
28 |
echo " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
tsts0=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
echo " --> scala collatz.scala did not run successfully" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
tsts0=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
# var, .par return, ListBuffer test
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
#
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
38 |
if [ $tsts0 -eq 0 ]
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
40 |
echo "collatz.scala does not contain var, return etc?" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
41 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
42 |
if (scala_vars tmp)
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
43 |
then
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
44 |
echo " --> test failed" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
45 |
tsts=$(( 1 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
46 |
else
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
47 |
echo " --> success" | tee -a $out
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
48 |
tsts=$(( 0 ))
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
49 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
50 |
fi
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
51 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
52 |
###rm tmp
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
53 |
|
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
54 |
|