Travis: travis_trigger.sh script.
[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 [ "${DO_SELF_HOST}" ]; then
26 if [ "${NO_SELF_HOST}" ]; then
27 echo "Skipping ${ACTION} of ${MAL_IMPL} self-host"
28 exit 0
29 fi
30 if [ "${ACTION}" = "perf" -a "${NO_SELF_HOST_PERF}" ]; then
31 echo "Skipping only perf test for ${MAL_IMPL} self-host"
32 exit 0
33 fi
34 fi
35
36 mode_var=${MAL_IMPL:-${IMPL}}_MODE
37 mode_val=${!mode_var}
38
39 MAKE="make ${mode_val:+${mode_var}=${mode_val}}"
40
41 # If NO_DOCKER is blank then launch use a docker image, otherwise use
42 # the Travis image/tools directly.
43 if [ -z "${NO_DOCKER}" ]; then
44 img_impl=$(echo "${MAL_IMPL:-${IMPL}}" | tr '[:upper:]' '[:lower:]')
45 # We could just use make DOCKERIZE=1 instead but that does add
46 # non-trivial startup overhead for each step.
47 MAKE="docker run -it -u $(id -u) -v `pwd`:/mal kanaka/mal-test-${img_impl} ${MAKE}"
48 fi
49
50 case "${ACTION}" in
51 build)
52 # rpython often fails on step9 in compute_vars_longevity
53 # so build step9, then continue wit the full build
54 if [ "${BUILD_IMPL}" = "rpython" ]; then
55 ${MAKE} -C "${BUILD_IMPL}" step9_try || true
56 fi
57 ${MAKE} -C ${BUILD_IMPL}
58 ;;
59 test|perf)
60 [ "${ACTION}" = "perf" ] && STEP=
61 if ! ${MAKE} TEST_OPTS="${TEST_OPTS}" \
62 ${MAL_IMPL:+MAL_IMPL=${MAL_IMPL}} \
63 ${REGRESS:+REGRESS=${REGRESS}} \
64 ${ACTION}^${IMPL}${STEP:+^${STEP}}; then
65 # print debug-file on error
66 cat ${ACTION}.err
67 false
68 fi
69 ;;
70 esac