cw2_marking/cw2_test.sh
changeset 1039 86d59b074abe
parent 980 4f422766763f
--- a/cw2_marking/cw2_test.sh	Fri Sep 18 10:57:24 2026 +0100
+++ b/cw2_marking/cw2_test.sh	Fri Sep 18 10:58:01 2026 +0100
@@ -1,7 +1,7 @@
-#!/bin/zsh
+#!/bin/zsh -o pipefail
 
 # to make the script fail safely
-set -euo pipefail
+#set -euo pipefail
 
 
 out=${1:-output}
@@ -24,22 +24,23 @@
 # compilation tests
 
 function scala_compile {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" amm -s "$1" 2> c$out 1> c$out)
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" amm -s "$1" 2> e$out 1> c$out)
 }
 
 # functional tests
 
 function scala_assert {
   rm -rf /Users/cu/.ammonite/cache/3.*/* 2> /dev/null ;  
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g -XX:MaxJavaStackTraceDepth=10" amm -s "$1" 1>> $out 2>> $out)
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g -XX:MaxJavaStackTraceDepth=10" amm --no-warn -s "$1" 1>> $out 2>> $out)
 }
 
 function scala_fail {
-  #rm -rf /Users/cu/.ammonite/cache/3.0.0-M2/* 2> /dev/null ;  
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g -XX:MaxJavaStackTraceDepth=10" amm -s "$1") # 1>> $out 2>> $out)
+  rm -rf /Users/cu/.ammonite/cache/3.*/* 2> /dev/null ;  
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g -XX:MaxJavaStackTraceDepth=10" amm --no-warn  -s "$1") # 1>> $out 2>> $out)
 }
 
-
+# remove @main
+gsed -i -e "s|@main||g" cw02.sc
 
 ### compilation test
 
@@ -51,8 +52,8 @@
     tsts=$(( 0 ))
 else
     echo -e "   --> AMM DID NOT compile cw02.sc\n" | tee -a $out
-    cat c$out | tee -a $out
-    echo -e "\n\n" >> $out
+    tail -25 e$out | pr -to10 | tee -a $out
+    echo -e "\n\n" | tee -a $out
     tsts=$(( 1 ))
 fi
 
@@ -74,7 +75,7 @@
 	echo -e "   --> FAILED\n" | tee -a $out
 	echo -e "       instead it generates:\n" | tee -a $out
 	(scala_fail "c1a.sc" || true) | tee -a $out
-	echo -e "\n\n" >> $out
+	echo -e "\n\n" | tee -a $out
     fi
 fi
 
@@ -84,7 +85,7 @@
 
 if [ $tsts -eq 0 ]
 then
-  echo -e "2) Tokenise test with example files (does it raise an exception):\n" | tee -a $out
+  echo -e "2) Tokenise tests with example files (no exception is raised):\n" | tee -a $out
   cat cw02.sc c3_add.sc > cw023_add.sc  
   if (scala_assert "c3.sc")
   then
@@ -121,15 +122,16 @@
 if [ $tsts -eq 0 ]
 then
     echo -e "4) Are regex constructors all primitive?\n" | tee -a $out
-    echo -e "   For example, RANGE.toString == \"RANGE\"\n" | tee -a $out
+    echo -e "   For example, PLUS.toString == \"PLUS\"" | tee -a $out
+    echo -e "                NTIMES.toString == \"NTIMES\"\n" | tee -a $out  
     if (scala_assert "c5.sc")
     then
-	echo -e "   --> FAILED\n" | tee -a $out
-	tail -25 $out | pr -to10
-	echo -e "\n\n" >> $out
-    else
 	echo -e "   --> success (+ 2.0 Marks)\n" | tee -a $out
 	marks=$(( marks + 2.0 ))
+    else
+	echo -e "   --> FAILED\n" | tee -a $out
+	#tail -25 $out | pr -to10
+	#echo -e "\n\n" | tee -a $out
     fi
 fi