Merge pull request #514 from alimpfard/jq-fix
[jackhill/mal.git] / .travis_test.sh
1 #!/bin/bash
2
3 set -ex
4
5 ACTION=${1}
6 IMPL=${2}
7
8 # Environment variable configuration
9 BUILD_IMPL=${BUILD_IMPL:-${IMPL}}
10 TEST_OPTS="${TEST_OPTS} --debug-file ../../${ACTION}.err"
11
12 if [ "${DO_SELF_HOST}" ]; then
13 MAL_IMPL=${IMPL}
14 IMPL=mal
15 fi
16 if [ "${DO_HARD}" ]; then
17 TEST_OPTS="${TEST_OPTS} --hard"
18 fi
19
20 echo "ACTION: ${ACTION}"
21 echo "IMPL: ${IMPL}"
22 echo "BUILD_IMPL: ${BUILD_IMPL}"
23 echo "MAL_IMPL: ${MAL_IMPL}"
24
25 if [ "${NO_PERF}" -a "${ACTION}" = "perf" ]; then
26 echo "Skipping perf test"
27 exit 0
28 fi
29 if [ "${NO_SELF_HOST}" -a "${DO_SELF_HOST}" ]; then
30 echo "Skipping ${ACTION} of ${MAL_IMPL} self-host"
31 exit 0
32 fi
33 if [ "${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
36 fi
37
38 raw_mode_var=${MAL_IMPL:-${IMPL}}_MODE
39 mode_var=${raw_mode_var/./__}
40 mode_val=${!mode_var}
41
42 MAKE="make ${mode_val:+${mode_var}=${mode_val}}"
43
44 # If NO_DOCKER is blank then launch use a docker image, otherwise use
45 # the Travis image/tools directly.
46 if [ -z "${NO_DOCKER}" ]; then
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.
50 MAKE="docker run -it -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl%%-mal} ${MAKE}"
51 fi
52
53 case "${ACTION}" in
54 build)
55 # rpython often fails on step9 in compute_vars_longevity
56 # so build step9, then continue with the full build
57 if [ "${BUILD_IMPL}" = "rpython" ]; then
58 ${MAKE} -C "impls/${BUILD_IMPL}" step9_try || true
59 fi
60 ${MAKE} -C "impls/${BUILD_IMPL}"
61 ;;
62 test|perf)
63 [ "${ACTION}" = "perf" ] && STEP=
64 if ! ${MAKE} TEST_OPTS="${TEST_OPTS}" \
65 ${MAL_IMPL:+MAL_IMPL=${MAL_IMPL}} \
66 ${REGRESS:+REGRESS=${REGRESS}} \
67 ${HARD:+HARD=${HARD}} \
68 ${DEFERRABLE:+DEFERRABLE=${DEFERRABLE}} \
69 ${OPTIONAL:+OPTIONAL=${OPTIONAL}} \
70 ${ACTION}^${IMPL}${STEP:+^${STEP}}; then
71 # print debug-file on error
72 cat ${ACTION}.err
73 false
74 fi
75 ;;
76 esac