Finish step8
[jackhill/mal.git] / .travis_test.sh
CommitLineData
7755014c
JM
1#!/bin/bash
2
3set -ex
4
531a98a9
JM
5ACTION=${1}
6IMPL=${2}
531a98a9 7
108d07a2 8# Environment variable configuration
a003046c 9BUILD_IMPL=${BUILD_IMPL:-${IMPL}}
8a19f603 10TEST_OPTS="${TEST_OPTS} --debug-file ../../${ACTION}.err"
a003046c 11
108d07a2 12if [ "${DO_SELF_HOST}" ]; then
7864f19b
JM
13 MAL_IMPL=${IMPL}
14 IMPL=mal
108d07a2
JM
15fi
16if [ "${DO_HARD}" ]; then
17 TEST_OPTS="${TEST_OPTS} --hard"
18fi
2d76e877 19
531a98a9
JM
20echo "ACTION: ${ACTION}"
21echo "IMPL: ${IMPL}"
a003046c 22echo "BUILD_IMPL: ${BUILD_IMPL}"
531a98a9
JM
23echo "MAL_IMPL: ${MAL_IMPL}"
24
a85482fe
JM
25if [ "${NO_PERF}" -a "${ACTION}" = "perf" ]; then
26 echo "Skipping perf test"
27 exit 0
28fi
29if [ "${NO_SELF_HOST}" -a "${DO_SELF_HOST}" ]; then
30 echo "Skipping ${ACTION} of ${MAL_IMPL} self-host"
31 exit 0
32fi
33if [ "${NO_SELF_HOST_PERF}" -a "${DO_SELF_HOST}" -a "${ACTION}" = "perf" ]; then
34 echo "Skipping only perf test for ${MAL_IMPL} self-host"
35 exit 0
7864f19b
JM
36fi
37
e9e171d1
GL
38raw_mode_var=${MAL_IMPL:-${IMPL}}_MODE
39mode_var=${raw_mode_var/./__}
108d07a2
JM
40mode_val=${!mode_var}
41
a003046c
JM
42MAKE="make ${mode_val:+${mode_var}=${mode_val}}"
43
6ce7b0ed
JM
44# If NO_DOCKER is blank then launch use a docker image, otherwise use
45# the Travis image/tools directly.
a003046c 46if [ -z "${NO_DOCKER}" ]; then
7864f19b
JM
47 img_impl=$(echo "${MAL_IMPL:-${IMPL}}" | tr '[:upper:]' '[:lower:]')
48 # We could just use make DOCKERIZE=1 instead but that does add
49 # non-trivial startup overhead for each step.
ff4e5f16 50 MAKE="docker run -it -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl%%-mal} ${MAKE}"
c727d1c8 51fi
6ce7b0ed 52
a003046c
JM
53case "${ACTION}" in
54build)
55 # rpython often fails on step9 in compute_vars_longevity
1e9eb423 56 # so build step9, then continue with the full build
a003046c 57 if [ "${BUILD_IMPL}" = "rpython" ]; then
8a19f603 58 ${MAKE} -C "impls/${BUILD_IMPL}" step9_try || true
a003046c 59 fi
8a19f603 60 ${MAKE} -C "impls/${BUILD_IMPL}"
a003046c
JM
61 ;;
62test|perf)
108d07a2
JM
63 [ "${ACTION}" = "perf" ] && STEP=
64 if ! ${MAKE} TEST_OPTS="${TEST_OPTS}" \
a003046c 65 ${MAL_IMPL:+MAL_IMPL=${MAL_IMPL}} \
108d07a2 66 ${REGRESS:+REGRESS=${REGRESS}} \
77fd710c
JM
67 ${HARD:+HARD=${HARD}} \
68 ${DEFERRABLE:+DEFERRABLE=${DEFERRABLE}} \
69 ${OPTIONAL:+OPTIONAL=${OPTIONAL}} \
108d07a2 70 ${ACTION}^${IMPL}${STEP:+^${STEP}}; then
a003046c
JM
71 # print debug-file on error
72 cat ${ACTION}.err
73 false
74 fi
75 ;;
76esac