Skip to content

Commit 31d176d

Browse files
committed
Merge branch 'jk/test-output'
When TEST_OUTPUT_DIRECTORY setting is used, it was handled somewhat inconsistently between the test framework and t/Makefile, and logic to summarize the results looked at a wrong place. * jk/test-output: t/Makefile: don't define TEST_RESULTS_DIRECTORY recursively test output: respect $TEST_OUTPUT_DIRECTORY t/Makefile: fix result handling with TEST_OUTPUT_DIRECTORY
2 parents 7e2d574 + b3e0c4e commit 31d176d

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,6 +2159,9 @@ GIT-BUILD-OPTIONS: FORCE
21592159
@echo NO_PERL=\''$(subst ','\'',$(subst ','\'',$(NO_PERL)))'\' >>$@
21602160
@echo NO_PYTHON=\''$(subst ','\'',$(subst ','\'',$(NO_PYTHON)))'\' >>$@
21612161
@echo NO_UNIX_SOCKETS=\''$(subst ','\'',$(subst ','\'',$(NO_UNIX_SOCKETS)))'\' >>$@
2162+
ifdef TEST_OUTPUT_DIRECTORY
2163+
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@
2164+
endif
21622165
ifdef GIT_TEST_OPTS
21632166
@echo GIT_TEST_OPTS=\''$(subst ','\'',$(subst ','\'',$(GIT_TEST_OPTS)))'\' >>$@
21642167
endif

t/Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ PROVE ?= prove
1515
DEFAULT_TEST_TARGET ?= test
1616
TEST_LINT ?= test-lint-duplicates test-lint-executable
1717

18+
ifdef TEST_OUTPUT_DIRECTORY
19+
TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
20+
else
21+
TEST_RESULTS_DIRECTORY = test-results
22+
endif
23+
1824
# Shell quote;
1925
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
2026
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
27+
TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
2128

2229
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
2330
TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
@@ -36,10 +43,10 @@ $(T):
3643
@echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
3744

3845
pre-clean:
39-
$(RM) -r test-results
46+
$(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
4047

4148
clean-except-prove-cache:
42-
$(RM) -r 'trash directory'.* test-results
49+
$(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
4350
$(RM) -r valgrind/bin
4451

4552
clean: clean-except-prove-cache
@@ -65,7 +72,7 @@ aggregate-results-and-cleanup: $(T)
6572
$(MAKE) clean
6673

6774
aggregate-results:
68-
for f in test-results/t*-*.counts; do \
75+
for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
6976
echo "$$f"; \
7077
done | '$(SHELL_PATH_SQ)' ./aggregate-results.sh
7178

t/test-lib.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ done,*)
5454
# do not redirect again
5555
;;
5656
*' --tee '*|*' --va'*)
57-
mkdir -p test-results
58-
BASE=test-results/$(basename "$0" .sh)
57+
mkdir -p "$TEST_OUTPUT_DIRECTORY/test-results"
58+
BASE="$TEST_OUTPUT_DIRECTORY/test-results/$(basename "$0" .sh)"
5959
(GIT_TEST_TEE_STARTED=done ${SHELL_PATH} "$0" "$@" 2>&1;
6060
echo $? > $BASE.exit) | tee $BASE.out
6161
test "$(cat $BASE.exit)" = 0

t/valgrind/analyze.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#!/bin/sh
22

3-
out_prefix=$(dirname "$0")/../test-results/valgrind.out
3+
# Get TEST_OUTPUT_DIRECTORY from GIT-BUILD-OPTIONS if it's there...
4+
. "$(dirname "$0")/../../GIT-BUILD-OPTIONS"
5+
# ... otherwise set it to the default value.
6+
: ${TEST_OUTPUT_DIRECTORY=$(dirname "$0")/..}
7+
48
output=
59
count=0
610
total_count=0
@@ -115,7 +119,7 @@ handle_one () {
115119
finish_output
116120
}
117121

118-
for test_script in "$(dirname "$0")"/../test-results/*.out
122+
for test_script in "$TEST_OUTPUT_DIRECTORY"/test-results/*.out
119123
do
120124
handle_one $test_script
121125
done

0 commit comments

Comments
 (0)