source: trunk/.circleci/run-tests.sh

Last change on this file was fa03478, checked in by Jean-Paul Calderone <exarkun@…>, at 2023-04-28T18:29:21Z

Perhaps this is the correct way to locate the tox-managed venv

  • Property mode set to 100755
File size: 3.1 KB
Line 
1#!/bin/bash
2
3# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
4set -euxo pipefail
5
6# The filesystem location of the root of a virtualenv we can use to get/build
7# wheels.
8BOOTSTRAP_VENV="$1"
9shift
10
11# The filesystem location of the root of the project source.  We need this to
12# know what wheels to get/build, of course.
13PROJECT_ROOT="$1"
14shift
15
16ALLOWED_FAILURE="$1"
17shift
18
19ARTIFACTS=$1
20shift
21
22TAHOE_LAFS_TOX_ENVIRONMENT=$1
23shift
24
25TAHOE_LAFS_TOX_ARGS=$1
26shift || :
27
28if [ -n "${ARTIFACTS}" ]; then
29    # If given an artifacts path, prepare to have some artifacts created
30    # there.  The integration tests don't produce any artifacts; that is the
31    # case where we expect not to end up here.
32
33    # Make sure we can actually write things to this directory.
34    mkdir -p "${ARTIFACTS}"
35
36    SUBUNIT2="${ARTIFACTS}"/results.subunit2
37
38    # Use an intermediate directory here because CircleCI extracts some label
39    # information from its name.
40    JUNITXML="${ARTIFACTS}"/junit/unittests/results.xml
41else
42    SUBUNIT2=""
43    JUNITXML=""
44fi
45
46# A prefix for the test command that ensure it will exit after no more than a
47# certain amount of time.  Ideally, we would only enforce a "silent" period
48# timeout but there isn't obviously a ready-made tool for that.  The unit test
49# suite only takes about 5 - 6 minutes on CircleCI right now.  The integration
50# tests are a bit longer than that.  45 minutes seems like a moderately safe
51# window.
52#
53# This is primarily aimed at catching hangs on the PyPy job which runs for
54# about 21 minutes and then gets killed by CircleCI in a way that fails the
55# job and bypasses our "allowed failure" logic.
56TIMEOUT="timeout --kill-after 1m 45m"
57
58# Run the test suite as a non-root user.  This is the expected usage some
59# small areas of the test suite assume non-root privileges (such as unreadable
60# files being unreadable).
61#
62# Also run with /tmp as a workdir because the non-root user won't be able to
63# create the tox working filesystem state in the source checkout because it is
64# owned by root.
65#
66# Send the output directly to a file because transporting the binary subunit2
67# via tox and then scraping it out is hideous and failure prone.
68export SUBUNITREPORTER_OUTPUT_PATH="${SUBUNIT2}"
69export TAHOE_LAFS_TRIAL_ARGS="${TAHOE_LAFS_TRIAL_ARGS:---reporter=subunitv2-file --rterrors}"
70export PIP_NO_INDEX="1"
71
72# Make output unbuffered, so progress reports from subunitv2-file get streamed
73# and notify CircleCI we're still alive.
74export PYTHONUNBUFFERED=1
75
76if [ "${ALLOWED_FAILURE}" = "yes" ]; then
77    alternative="true"
78else
79    alternative="false"
80fi
81
82WORKDIR=/tmp/tahoe-lafs.tox
83${TIMEOUT} ${BOOTSTRAP_VENV}/bin/tox \
84    -c ${PROJECT_ROOT}/tox.ini \
85    --workdir "${WORKDIR}" \
86    -e "${TAHOE_LAFS_TOX_ENVIRONMENT}" \
87    ${TAHOE_LAFS_TOX_ARGS} || "${alternative}"
88
89if [ -n "${ARTIFACTS}" ]; then
90    if [ ! -e "${SUBUNIT2}" ]; then
91        echo "subunitv2 output file does not exist: ${SUBUNIT2}"
92        exit 1
93    fi
94
95    # Create a junitxml results area.
96    mkdir -p "$(dirname "${JUNITXML}")"
97
98    "${WORKDIR}/${TAHOE_LAFS_TOX_ENVIRONMENT}/bin/subunit2junitxml" < "${SUBUNIT2}" > "${JUNITXML}" || "${alternative}"
99fi
Note: See TracBrowser for help on using the repository browser.