Skip to content

Commit 30fe9b2

Browse files
committed
Merge branch 'dg/subtree-test-cleanup'
Test cleanups for the subtree project. * dg/subtree-test-cleanup: contrib/subtree: Handle '--prefix' argument with a slash appended contrib/subtree: Make each test self-contained contrib/subtree: Add split tests contrib/subtree: Add merge tests contrib/subtree: Add tests for subtree add contrib/subtree: Add test for missing subtree contrib/subtree: Clean and refactor test code
2 parents 23bc35f + d16031c commit 30fe9b2

File tree

3 files changed

+956
-443
lines changed

3 files changed

+956
-443
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ while [ $# -gt 0 ]; do
9090
--annotate) annotate="$1"; shift ;;
9191
--no-annotate) annotate= ;;
9292
-b) branch="$1"; shift ;;
93-
-P) prefix="$1"; shift ;;
93+
-P) prefix="${1%/}"; shift ;;
9494
-m) message="$1"; shift ;;
9595
--no-prefix) prefix= ;;
9696
--onto) onto="$1"; shift ;;

contrib/subtree/t/Makefile

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,23 @@ TAR ?= $(TAR)
1313
RM ?= rm -f
1414
PROVE ?= prove
1515
DEFAULT_TEST_TARGET ?= test
16+
TEST_LINT ?= test-lint
17+
18+
ifdef TEST_OUTPUT_DIRECTORY
19+
TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
20+
else
21+
TEST_RESULTS_DIRECTORY = ../../../t/test-results
22+
endif
1623

1724
# Shell quote;
1825
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
26+
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
27+
TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))
1928

20-
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
29+
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
30+
TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
31+
TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
32+
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
2133

2234
all: $(DEFAULT_TEST_TARGET)
2335

@@ -26,20 +38,22 @@ test: pre-clean $(TEST_LINT)
2638

2739
prove: pre-clean $(TEST_LINT)
2840
@echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
29-
$(MAKE) clean
41+
$(MAKE) clean-except-prove-cache
3042

3143
$(T):
3244
@echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
3345

3446
pre-clean:
35-
$(RM) -r test-results
47+
$(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
3648

37-
clean:
38-
$(RM) -r 'trash directory'.* test-results
49+
clean-except-prove-cache:
50+
$(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
3951
$(RM) -r valgrind/bin
52+
53+
clean: clean-except-prove-cache
4054
$(RM) .prove
4155

42-
test-lint: test-lint-duplicates test-lint-executable
56+
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax
4357

4458
test-lint-duplicates:
4559
@dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
@@ -51,12 +65,15 @@ test-lint-executable:
5165
test -z "$$bad" || { \
5266
echo >&2 "non-executable tests:" $$bad; exit 1; }
5367

68+
test-lint-shell-syntax:
69+
@'$(PERL_PATH_SQ)' ../../../t/check-non-portable-shell.pl $(T) $(THELPERS)
70+
5471
aggregate-results-and-cleanup: $(T)
5572
$(MAKE) aggregate-results
5673
$(MAKE) clean
5774

5875
aggregate-results:
59-
for f in ../../../t/test-results/t*-*.counts; do \
76+
for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
6077
echo "$$f"; \
6178
done | '$(SHELL_PATH_SQ)' ../../../t/aggregate-results.sh
6279

0 commit comments

Comments
 (0)