Skip to content

Commit

Permalink
Merge branch 'dg/subtree-test-cleanup'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jeff King committed Dec 1, 2015
2 parents 23bc35f + d16031c commit 30fe9b2
Show file tree
Hide file tree
Showing 3 changed files with 956 additions and 443 deletions.
2 changes: 1 addition & 1 deletion contrib/subtree/git-subtree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ while [ $# -gt 0 ]; do
--annotate) annotate="$1"; shift ;;
--no-annotate) annotate= ;;
-b) branch="$1"; shift ;;
-P) prefix="$1"; shift ;;
-P) prefix="${1%/}"; shift ;;
-m) message="$1"; shift ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
Expand Down
31 changes: 24 additions & 7 deletions contrib/subtree/t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@ TAR ?= $(TAR)
RM ?= rm -f
PROVE ?= prove
DEFAULT_TEST_TARGET ?= test
TEST_LINT ?= test-lint

ifdef TEST_OUTPUT_DIRECTORY
TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results
else
TEST_RESULTS_DIRECTORY = ../../../t/test-results
endif

# Shell quote;
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY))

T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))

all: $(DEFAULT_TEST_TARGET)

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

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

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

pre-clean:
$(RM) -r test-results
$(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'

clean:
$(RM) -r 'trash directory'.* test-results
clean-except-prove-cache:
$(RM) -r 'trash directory'.* '$(TEST_RESULTS_DIRECTORY_SQ)'
$(RM) -r valgrind/bin

clean: clean-except-prove-cache
$(RM) .prove

test-lint: test-lint-duplicates test-lint-executable
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax

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

test-lint-shell-syntax:
@'$(PERL_PATH_SQ)' ../../../t/check-non-portable-shell.pl $(T) $(THELPERS)

aggregate-results-and-cleanup: $(T)
$(MAKE) aggregate-results
$(MAKE) clean

aggregate-results:
for f in ../../../t/test-results/t*-*.counts; do \
for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \
echo "$$f"; \
done | '$(SHELL_PATH_SQ)' ../../../t/aggregate-results.sh

Expand Down
Loading

0 comments on commit 30fe9b2

Please sign in to comment.