equal
deleted
inserted
replaced
1 #!/bin/zsh |
1 #!/bin/zsh -o pipefail |
2 |
2 |
3 # to make the script fail safely |
3 # to make the script fail safely |
4 set -euo pipefail |
4 #set -euo pipefail |
5 |
5 |
6 |
6 |
7 out=${1:-output} |
7 out=${1:-output} |
8 |
8 |
9 echo -e "" > $out |
9 echo -e "" > $out |
29 |
29 |
30 # functional tests |
30 # functional tests |
31 setopt no_nomatch |
31 setopt no_nomatch |
32 |
32 |
33 function scala_assert { |
33 function scala_assert { |
34 rm -rf /Users/cu/.ammonite/cache/3.0.0-M2/* 1> /dev/null 2> /dev/null ; |
34 rm -rf /Users/cu/.ammonite/cache/3.* 1> /dev/null 2> /dev/null ; |
35 (ulimit -t 300; JAVA_OPTS="-Xmx1g -XX:MaxJavaStackTraceDepth=10" amm -s "$1" 1>> $out 2>> $out) |
35 (ulimit -t 200; JAVA_OPTS="-Xmx1g -XX:MaxJavaStackTraceDepth=10" amm --no-warn -s "$1" 1>> $out 2>> $out) |
36 } |
36 } |
37 |
37 |
38 function scala_fail { |
38 function scala_fail { |
39 rm -rf /Users/cu/.ammonite/cache/3.0.0-M2/* 1> /dev/null 2> /dev/null ; |
39 rm -rf /Users/cu/.ammonite/cache/3.* 1> /dev/null 2> /dev/null ; |
40 (ulimit -t 300; JAVA_OPTS="-Xmx1g -XX:MaxJavaStackTraceDepth=10" amm -s "$1" | tee -a $out) |
40 (ulimit -t 200; JAVA_OPTS="-Xmx1g -XX:MaxJavaStackTraceDepth=10" amm --no-warn -s "$1" | tee -a $out) |
41 } |
41 } |
|
42 |
|
43 # remove @main |
|
44 gsed -i -e "s|^@main||g" cw05.sc |
42 |
45 |
43 |
46 |
44 |
47 |
45 ### compilation test |
48 ### compilation test |
46 |
49 |
50 then |
53 then |
51 echo -e " --> yes cw05.sc compiles\n" | tee -a $out |
54 echo -e " --> yes cw05.sc compiles\n" | tee -a $out |
52 tsts=$(( 0 )) |
55 tsts=$(( 0 )) |
53 else |
56 else |
54 echo -e " --> AMM DID NOT compile cw05.sc\n" | tee -a $out |
57 echo -e " --> AMM DID NOT compile cw05.sc\n" | tee -a $out |
55 cat c$out | tee -a $out |
58 #cat c$out | tee -a $out |
56 tsts=$(( 1 )) |
59 tsts=$(( 1 )) |
57 fi |
60 fi |
58 |
61 |
59 |
62 |
60 ### tokenise test |
63 ### tokenise test |
68 echo -e " --> success (+ 2.0 Marks)\n" | tee -a $out |
71 echo -e " --> success (+ 2.0 Marks)\n" | tee -a $out |
69 #cat $out | tee -a $out |
72 #cat $out | tee -a $out |
70 marks=$(( marks + 2.0 )) |
73 marks=$(( marks + 2.0 )) |
71 else |
74 else |
72 echo -e " --> FAILED\n" | tee -a $out |
75 echo -e " --> FAILED\n" | tee -a $out |
73 cat $out | tee -a $out |
76 #cat $out | tee -a $out |
74 fi |
77 fi |
75 fi |
78 fi |
76 |
79 |
77 ### parsing test |
80 ### parsing test |
78 |
81 |
93 else |
96 else |
94 END=$(date +%s) |
97 END=$(date +%s) |
95 DIFF=$(( $END - $START )) |
98 DIFF=$(( $END - $START )) |
96 echo -e " This test ran for $DIFF seconds" | tee -a $out |
99 echo -e " This test ran for $DIFF seconds" | tee -a $out |
97 echo -e " --> FAILED\n" | tee -a $out |
100 echo -e " --> FAILED\n" | tee -a $out |
98 cat $out | tee -a $out |
101 #cat $out | tee -a $out |
99 fi |
102 fi |
100 fi |
103 fi |
101 |
104 |
102 ### mand test |
105 ### mand test |
103 echo >> $out |
106 echo >> $out |
106 |
109 |
107 tstsB=$(( 1 )) |
110 tstsB=$(( 1 )) |
108 |
111 |
109 if [ $tsts -eq 0 ] |
112 if [ $tsts -eq 0 ] |
110 then |
113 then |
111 echo -e "3.1) Generating ll-file for mand.fun:\n" | tee -a $out |
114 echo -e "3.1) Generating ll-file for mand.fun:" | tee -a $out |
112 echo >> $out |
115 echo >> $out |
113 cat cw05.sc c3_add.sc > cw051_add.sc |
116 cat cw05.sc c3_add.sc > cw051_add.sc |
114 |
117 |
115 if (scala_assert "c3.sc") |
118 if (scala_assert "c3.sc") |
116 then |
119 then |
117 echo -e " --> success" | tee -a $out |
120 echo -e " --> success" | tee -a $out |
118 tstsB=$(( 0 )) |
121 tstsB=$(( 0 )) |
119 else |
122 else |
120 echo -e " --> FAIL\n" | tee -a $out |
123 echo -e " --> FAIL\n" | tee -a $out |
121 cat c$out >> $out |
124 cat c$out >> $out |
122 tail -25 $out | pr -to10 |
125 #tail -25 $out | pr -to10 |
123 tstsB=$(( 1 )) |
126 tstsB=$(( 1 )) |
124 fi |
127 fi |
125 fi |
128 fi |
126 |
129 |
|
130 echo >> $out |
127 if [ $tstsB -eq 0 ] |
131 if [ $tstsB -eq 0 ] |
128 then |
132 then |
129 echo -e "3.2) Running mand.ll and check its output" | tee -a $out |
133 echo -e "3.2) Running mand.ll and check its output" | tee -a $out |
130 if (scala_fail "c4.sc") |
134 if (scala_fail "c4.sc") |
131 then |
135 then |
132 echo -e " --> success (+ 12.0 Marks)\n" | tee -a $out |
136 echo -e " --> success (+ 8.0 Marks)\n" | tee -a $out |
133 marks=$(( marks + 12.0 )) |
137 marks=$(( marks + 8.0 )) |
134 else |
138 else |
135 echo -e " --> FAIL\n" | tee -a $out |
139 echo -e " --> FAIL\n" | tee -a $out |
136 echo -e " generated:" | tee -a $out |
140 echo -e " generated:" | tee -a $out |
137 cat "mand.ll" | pr -to10 |
141 cat "mand.ll" | pr -to10 |
138 #cat c$out >> $out |
142 #cat c$out >> $out |
154 then |
158 then |
155 echo -e " --> success" | tee -a $out |
159 echo -e " --> success" | tee -a $out |
156 tstsB=$(( 0 )) |
160 tstsB=$(( 0 )) |
157 else |
161 else |
158 echo -e " --> FAIL\n" | tee -a $out |
162 echo -e " --> FAIL\n" | tee -a $out |
159 cat c$out >> $out |
163 #cat c$out >> $out |
160 tail -25 $out | pr -to10 |
164 #tail -25 $out | pr -to10 |
161 tstsB=$(( 1 )) |
165 tstsB=$(( 1 )) |
162 fi |
166 fi |
163 fi |
167 fi |
164 |
168 |
165 if [ $tstsB -eq 0 ] |
169 if [ $tstsB -eq 0 ] |
166 then |
170 then |
167 echo -e "4.2) Running sqr.ll and check its output" | tee -a $out |
171 echo -e "4.2) Running sqr.ll and check its output" | tee -a $out |
168 if (scala_fail "c6.sc") |
172 if (scala_fail "c6.sc") |
169 then |
173 then |
170 echo -e " --> success (+ 6.0 Marks)\n" | tee -a $out |
174 echo -e " --> success (+ 5.0 Marks)\n" | tee -a $out |
171 marks=$(( marks + 6.0 )) |
175 marks=$(( marks + 5.0 )) |
172 else |
176 else |
173 echo -e " --> FAIL\n" | tee -a $out |
177 echo -e " --> FAIL\n" | tee -a $out |
174 echo -e " generated:" | tee -a $out |
178 echo -e " generated:" | tee -a $out |
175 cat "sqr.ll" | pr -to10 |
179 cat "sqr.ll" | pr -to10 |
176 #cat c$out >> $out |
180 #cat c$out >> $out |