testing2/danube_test2.sh
author Christian Urban <urbanc@in.tum.de>
Thu, 31 Oct 2019 09:20:43 +0000
changeset 294 7a945c3b86c7
parent 266 ca48ac1d3c3e
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
263
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
#!/bin/bash
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
# to make the script fail safely
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
set -euo pipefail
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
out=${1:-output}
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     8
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
echo "" > $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
echo -e "Below is the feedback for your submission for the advanced part of danube.scala" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
echo -e "" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
# compilation tests
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
function scala_compile {
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 263
diff changeset
    18
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out) 
263
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
}
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
# functional tests
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
function scala_assert {
266
ca48ac1d3c3e updated to 2.13
Christian Urban <urbanc@in.tum.de>
parents: 263
diff changeset
    24
  (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "") #2> /dev/null 1> /dev/null)
263
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
}
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
# purity test
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    29
function scala_vars {
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
   (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null)
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
}
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
# var, .par return, ListBuffer test
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
#
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
echo "danube.scala does not contain vars, returns etc?" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
if (scala_vars danube.scala)
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
then
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
  echo -e "  --> fail (make triple-sure your program conforms to the required format)" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
  tsts0=$(( 0 ))
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
else
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  echo -e "  --> success" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
  tsts0=$(( 0 )) 
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
fi
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
### compilation test
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
if  [ $tsts0 -eq 0 ]
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
then 
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
  echo "danube.scala runs?" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
  if (scala_compile danube.scala)
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
  then
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
    echo -e "  --> success" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
    tsts=$(( 0 ))
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
  else
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
    echo -e "  --> SCALA DID NOT RUN DANUBE.SCALA\n" >> $out  
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
    tsts=$(( 1 )) 
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
  fi
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
else
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
  tsts=$(( 1 ))     
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
fi
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
### danube groupById test
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
if [ $tsts -eq 0 ]
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
then
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
  echo "  val ls = List((\"1\", \"a\"), (\"2\", \"a\"), (\"1\", \"c\"), (\"2\", \"a\"), (\"1\", \"c\"))" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
  echo "  groupById(ls, Map()) == Map(1 -> List(c, c, a), 2 -> List(a, a))" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
  echo "      where the order in the lists is unimportant" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  if (scala_assert "danube.scala" "danube_test3.scala")
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
  then
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
      echo -e "  --> success" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
  else
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
      echo -e "  --> \n ONE TEST FAILED\n" >> $out  
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
  fi
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
fi
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
### danube processing tests
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
#if [ $tsts -eq 0 ]
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
#then
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
#  echo "  val good_ratings = process_ratings(ratings)" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
#  echo "  val movie_names = process_movies(movies)" >> $out  
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
#  echo "  " >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
#  echo "  good_ratings.length == 48580 " >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
#  echo "  movie_names.length == 9742 " >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
#
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
#  if (scala_assert "danube.scala" "danube_test2.scala") 
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
#  then
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
#    echo "  --> success" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
#  else
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
#    echo "  --> one of the tests failed" >> $out
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
#  fi
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
#fi
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
5a16bcb4105e updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
echo -e "\nFor other testcases please look at the template file." >> $out