marking2/danube_test.sh
changeset 264 ecd989eee8bd
parent 261 8997430d9765
child 283 ef5f62bf5987
--- a/marking2/danube_test.sh	Sat Feb 02 13:38:47 2019 +0000
+++ b/marking2/danube_test.sh	Wed Mar 20 21:50:20 2019 +0000
@@ -6,7 +6,12 @@
 
 out=${1:-output}
 
-echo "" > $out
+# read marks for CW7 part 1
+marks=$(( `tail -1 $out` ))
+
+echo $marks
+
+echo "" >> $out
 
 echo "Below is the feedback for your submission danube.scala" >> $out
 echo "" >> $out
@@ -15,32 +20,32 @@
 # compilation tests
 
 function scala_compile {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2>> $out 1>> $out) 
+    (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc "$1" 2>> $out 1>> $out)
 }
 
 # functional tests
 
 function scala_assert {
-  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
+  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -nc -i "$1" "$2" -e "") #2> /dev/null 1> /dev/null)
 }
 
 # purity test
 
 function scala_vars {
-   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
+   (egrep '\bvar\b|\breturn\b|ListBuffer|mutable' "$1" 2> /dev/null 1> /dev/null)
 }
 
 
 # var, .par return, ListBuffer test
 #
-echo "danube.scala does not contain vars, returns etc?" >> $out
+echo "danube.scala does not contain vars, returns etc?" | tee -a $out
 
 if (scala_vars danube.scala)
 then
-  echo "  --> fail (make triple-sure your program conforms to the required format)" >> $out
-  tsts0=$(( 0 ))
+  echo "  --> test failed" | tee -a $out
+  tsts0=$(( 1 ))  
 else
-  echo "  --> success" >> $out
+  echo "  --> success" | tee -a $out
   tsts0=$(( 0 )) 
 fi
 
@@ -49,14 +54,14 @@
 
 if  [ $tsts0 -eq 0 ]
 then 
-  echo "danube.scala runs?" >> $out
+  echo "danube.scala runs?" | tee -a $out
 
   if (scala_compile danube.scala)
   then
-    echo "  --> success" >> $out
+    echo "  --> success" | tee -a $out
     tsts=$(( 0 ))
   else
-    echo "  --> scala did not run danube.scala" >> $out
+    echo "  --> scala did not run danube.scala" | tee -a $out
     tsts=$(( 1 )) 
   fi
 else
@@ -67,15 +72,16 @@
 
 if [ $tsts -eq 0 ]
 then
-  echo "danube.scala tests:" >> $out
-  echo "  val movies_url = \"\"\"https://nms.kcl.ac.uk/christian.urban/movies.csv\"\"\"" >> $out
-  echo "  get_csv_url(movies_url).length == 9742" >> $out
+  echo "danube.scala tests:" | tee -a $out
+  echo "  val movies_url = \"\"\"https://nms.kcl.ac.uk/christian.urban/movies.csv\"\"\"" | tee -a $out
+  echo "  get_csv_url(movies_url).length == 9742" | tee -a $out
 
   if (scala_assert "danube.scala" "danube_test1.scala")
   then
-    echo "  --> success" >> $out
+      echo "  --> success" | tee -a $out
+      marks=$(( marks + 1 ))
   else
-    echo "  --> one of the tests failed" >> $out
+    echo "  --> one of the tests failed" | tee -a $out
   fi
 fi
 
@@ -83,17 +89,25 @@
 
 if [ $tsts -eq 0 ]
 then
-  echo "  val good_ratings = process_ratings(ratings)" >> $out
-  echo "  val movie_names = process_movies(movies)" >> $out  
-  echo "  " >> $out
-  echo "  good_ratings.length == 48580 " >> $out
-  echo "  movie_names.length == 9742 " >> $out
+  echo "  val good_ratings = process_ratings(ratings)" | tee -a $out
+  echo "  val movie_names = process_movies(movies)" | tee -a $out  
+  echo "  " | tee -a $out
+  echo "  good_ratings.length == 48580 " | tee -a $out
+  echo "  movie_names.length == 9742 " | tee -a $out
 
   if (scala_assert "danube.scala" "danube_test2.scala") 
   then
-    echo "  --> success" >> $out
+      echo "  --> success" | tee -a $out
+      marks=$(( marks + 1 ))
   else
-    echo "  --> one of the tests failed" >> $out
+    echo "  --> one of the tests failed" | tee -a $out
   fi
 fi
 
+
+
+## final marks
+echo "Overall mark for CW 7, Part 1 + 2" | tee -a $out
+echo "$marks" | tee -a $out
+
+