Skip to content

Commit a10fa46

Browse files
committed
Merge branch 'sr/reusable-test-runner-script'
Signed-off-by: Elijah Newren <[email protected]>
2 parents e5d8938 + 24f09bd commit a10fa46

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,11 @@ jobs:
2424
printf '#!/bin/sh\n\nexec python "$@"\n' >python3 &&
2525
2626
export PATH=$PWD:$PATH &&
27-
export PYTHONPATH=$PWD &&
28-
export TEST_SHELL_PATH=/bin/sh &&
2927
30-
failed=0 &&
31-
cd t &&
32-
for t in t[0-9]*.sh
33-
do
34-
printf '\n\n== %s ==\n' "$t" &&
35-
bash $t -q -v -x ||
36-
failed=$(($failed+1))
37-
done &&
38-
if test 0 != $failed
28+
if ! t/run_tests -q -v -x
3929
then
40-
mkdir ../failed &&
41-
tar czf ../failed/failed.tar.gz .
30+
mkdir failed &&
31+
tar czf failed/failed.tar.gz t
4232
exit 1
4333
fi
4434
- name: upload failed tests' directories

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ build:
1212
@echo Nothing to do: filter-repo is a script which needs no compilation.
1313

1414
test:
15-
cd t && time ./run_coverage
15+
time t/run_coverage
1616

1717
# fixup_locale might matter once we actually have translations, but right now
1818
# we don't. It might not even matter then, because python has a fallback podir.

t/run_coverage

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
set -eu
4+
35
orig_dir=$(cd $(dirname $0) && pwd -P)
46
tmpdir=$(mktemp -d)
57

@@ -16,16 +18,18 @@ EOF
1618

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

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

2628
cd $tmpdir
2729
coverage3 combine
2830
coverage3 html -d $orig_dir/report
2931
coverage3 report -m
3032
cd $orig_dir
3133
rm -rf $tmpdir
34+
35+
exit $exitcode

t/run_tests

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
cd $(dirname $0)
5+
6+
# Put git_filter_repo.py on the front of PYTHONPATH
7+
export PYTHONPATH="$PWD/..${PYTHONPATH:+:$PYTHONPATH}"
8+
9+
# We pretend filenames are unicode for two reasons: (1) because it exercises
10+
# more code, and (2) this setting will detect accidental use of unicode strings
11+
# for file/directory names when it should always be bytestrings.
12+
export PRETEND_UNICODE_ARGS=1
13+
14+
export TEST_SHELL_PATH=/bin/sh
15+
16+
failed=0
17+
18+
for t in t[0-9]*.sh
19+
do
20+
printf '\n\n== %s ==\n' "$t"
21+
bash $t "$@" || failed=$(($failed+1))
22+
done
23+
24+
if [ 0 -lt $failed ]
25+
then
26+
exit 1
27+
fi

0 commit comments

Comments
 (0)