marking/mark01a
author Christian Urban <urbanc@in.tum.de>
Thu, 06 Dec 2018 13:15:28 +0000
changeset 229 5549016ab10f
parent 122 90dd9c6162b3
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
64
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
122
90dd9c6162b3 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
     2
90dd9c6162b3 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
     3
# try this to make it fail safely
90dd9c6162b3 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
     4
set -eu -o pipefail -posix
90dd9c6162b3 updated
Christian Urban <urbanc@in.tum.de>
parents: 83
diff changeset
     5
#set -e
64
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
out=${1:-output}
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
echo "" > $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
echo "Below is the feedback and provisional mark for your submission" >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
echo "for assignment 6.  Please note all marks are provisional until" >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
echo "ratified by the assessment board -- this is not an official" >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
echo "results transcript." >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
echo "" >> $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
#alarm() { perl -e 'alarm shift; exec @ARGV' "$@"; }
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
#alarm 20 foo arg1
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
# compilation tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
function scala_compile {
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
  (scala "$1" 2> /dev/null 1> /dev/null) 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
}
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
# functional tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
function scala_assert {
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
  (scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null)
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
}
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
# marks for CW1 parts 1 + 2
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
marks=$(( 0 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
# compilation test
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
echo "collatz.scala runs?" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
if (scala_compile collatz.scala)
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
  echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
  tsts=$(( 0 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
  echo "  --> scala did not run collatz.scala" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
  tsts=$(( 1 )) 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
### collatz tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
  echo "  collatz(1) == 1" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
  echo "  collatz(2) == 2" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
  echo "  collatz(9) == 20" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
  echo "  collatz(9000) == 48" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
  if (scala_assert "collatz.scala" "../collatz_test1.scala")
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
    marks=$(( marks + 2 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
### collatz max tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  echo "  collatz_max(2) == (2, 2)" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
  echo "  collatz_max(77000) == (340, 52527)" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
  if (scala_assert "collatz.scala" "../collatz_test2.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
# compilation test
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
echo "trade.scala runs?" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
if (scala_compile trade.scala)
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
  echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
  tsts=$(( 0 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
  echo "  --> scala did not run trade.scala" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
  tsts=$(( 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
### trade times tests
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
  echo "  trade_times(List(3.0, 7.0, 2.0, 4.0)) == (2, 3)" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
  echo "  trade_times(List(28.0, 18.0, 20.0, 26.0, 24.0)) == (1, 3)" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
  if (scala_assert "trade.scala" "../trade_test1.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   121
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  echo "  get_page(\"GOOG\").length >= 3088" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
  echo "  get_page(\"AAPL\").length >= 9065" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
  echo "  get_page(\"FB\").length >= 1136" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
  if (scala_assert "trade.scala" "../trade_test2.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
  echo "  get_page(\"IBM\").last or head == \"1962-01-02,578.499985,578.499985,571.999991,571.999991,387200,2.260487\")" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
  echo "  process_page(\"IBM\").length == get_page(\"IBM\").length - 1" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
  if (scala_assert "trade.scala" "../trade_test3.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
if [ $tsts -eq 0 ]
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
  echo "  query_company(\"YHOO\") == (\"1996-07-24\", \"2000-01-03\")" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
  echo "  query_company(\"IBM\") == (\"1962-06-14\", \"2013-03-14\")" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
  echo "  query_company(\"BIDU\") == (\"2006-02-07\", \"2014-11-11\")" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
 if (scala_assert "trade.scala" "../trade_test4.scala") 
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
  then
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
    echo "  --> success" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
    marks=$(( marks + 1 ))
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
  else
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
    echo "  --> one of the tests failed" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
  fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
fi
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
## final marks
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
echo "Overall mark for Parts 1 and 2:" | tee -a $out
d6f97b562424 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
echo "$marks" | tee -a $out