Skip to content

Commit

Permalink
Merge branch 'sr/reusable-test-runner-script'
Browse files Browse the repository at this point in the history
Signed-off-by: Elijah Newren <[email protected]>
  • Loading branch information
newren committed Jun 7, 2021
2 parents e5d8938 + 24f09bd commit a10fa46
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,11 @@ jobs:
printf '#!/bin/sh\n\nexec python "$@"\n' >python3 &&
export PATH=$PWD:$PATH &&
export PYTHONPATH=$PWD &&
export TEST_SHELL_PATH=/bin/sh &&
failed=0 &&
cd t &&
for t in t[0-9]*.sh
do
printf '\n\n== %s ==\n' "$t" &&
bash $t -q -v -x ||
failed=$(($failed+1))
done &&
if test 0 != $failed
if ! t/run_tests -q -v -x
then
mkdir ../failed &&
tar czf ../failed/failed.tar.gz .
mkdir failed &&
tar czf failed/failed.tar.gz t
exit 1
fi
- name: upload failed tests' directories
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build:
@echo Nothing to do: filter-repo is a script which needs no compilation.

test:
cd t && time ./run_coverage
time t/run_coverage

# fixup_locale might matter once we actually have translations, but right now
# we don't. It might not even matter then, because python has a fallback podir.
Expand Down
14 changes: 9 additions & 5 deletions t/run_coverage
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -eu

orig_dir=$(cd $(dirname $0) && pwd -P)
tmpdir=$(mktemp -d)

Expand All @@ -16,16 +18,18 @@ EOF

export COVERAGE_PROCESS_START=$tmpdir/.coveragerc
export PYTHONPATH=$tmpdir:
# We pretend filenames are unicode for two reasons: (1) because it exercises
# more code, and (2) this setting will detect accidental use of unicode strings
# for file/directory names when it should always be bytestrings.
export PRETEND_UNICODE_ARGS=1

ls t939*.sh | xargs -n 1 bash
# Produce a coverage report, even if the tests fail
set +e
$orig_dir/run_tests
exitcode=$?
set -e

cd $tmpdir
coverage3 combine
coverage3 html -d $orig_dir/report
coverage3 report -m
cd $orig_dir
rm -rf $tmpdir

exit $exitcode
27 changes: 27 additions & 0 deletions t/run_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -eu

cd $(dirname $0)

# Put git_filter_repo.py on the front of PYTHONPATH
export PYTHONPATH="$PWD/..${PYTHONPATH:+:$PYTHONPATH}"

# We pretend filenames are unicode for two reasons: (1) because it exercises
# more code, and (2) this setting will detect accidental use of unicode strings
# for file/directory names when it should always be bytestrings.
export PRETEND_UNICODE_ARGS=1

export TEST_SHELL_PATH=/bin/sh

failed=0

for t in t[0-9]*.sh
do
printf '\n\n== %s ==\n' "$t"
bash $t "$@" || failed=$(($failed+1))
done

if [ 0 -lt $failed ]
then
exit 1
fi

0 comments on commit a10fa46

Please sign in to comment.