Skip to content

Commit 9d58241

Browse files
committed
Merge branch 'es/chainlint'
Revamp chainlint script for our tests. * es/chainlint: chainlint: colorize problem annotations and test delimiters t: retire unused chainlint.sed t/Makefile: teach `make test` and `make prove` to run chainlint.pl test-lib: replace chainlint.sed with chainlint.pl test-lib: retire "lint harder" optimization hack t/chainlint: add more chainlint.pl self-tests chainlint.pl: allow `|| echo` to signal failure upstream of a pipe chainlint.pl: complain about loops lacking explicit failure handling chainlint.pl: don't flag broken &&-chain if failure indicated explicitly chainlint.pl: don't flag broken &&-chain if `$?` handled explicitly chainlint.pl: don't require `&` background command to end with `&&` t/Makefile: apply chainlint.pl to existing self-tests chainlint.pl: don't require `return|exit|continue` to end with `&&` chainlint.pl: validate test scripts in parallel chainlint.pl: add parser to identify test definitions chainlint.pl: add parser to validate tests chainlint.pl: add POSIX shell parser chainlint.pl: add POSIX shell lexical analyzer t: add skeleton chainlint.pl
2 parents 298a958 + 7c04aa7 commit 9d58241

File tree

73 files changed

+1479
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1479
-449
lines changed

contrib/buildsystems/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ if(NOT ${CMAKE_BINARY_DIR}/CMakeCache.txt STREQUAL ${CACHE_PATH})
10761076
"string(REPLACE \"\${GIT_BUILD_DIR_REPL}\" \"GIT_BUILD_DIR=\\\"$TEST_DIRECTORY/../${BUILD_DIR_RELATIVE}\\\"\" content \"\${content}\")\n"
10771077
"file(WRITE ${CMAKE_SOURCE_DIR}/t/test-lib.sh \${content})")
10781078
#misc copies
1079-
file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.sed DESTINATION ${CMAKE_BINARY_DIR}/t/)
1079+
file(COPY ${CMAKE_SOURCE_DIR}/t/chainlint.pl DESTINATION ${CMAKE_BINARY_DIR}/t/)
10801080
file(COPY ${CMAKE_SOURCE_DIR}/po/is.po DESTINATION ${CMAKE_BINARY_DIR}/po/)
10811081
file(COPY ${CMAKE_SOURCE_DIR}/mergetools/tkdiff DESTINATION ${CMAKE_BINARY_DIR}/mergetools/)
10821082
file(COPY ${CMAKE_SOURCE_DIR}/contrib/completion/git-prompt.sh DESTINATION ${CMAKE_BINARY_DIR}/contrib/completion/)

t/Makefile

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,21 @@ CHAINLINTTMP_SQ = $(subst ','\'',$(CHAINLINTTMP))
3636

3737
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
3838
THELPERS = $(sort $(filter-out $(T),$(wildcard *.sh)))
39+
TLIBS = $(sort $(wildcard lib-*.sh)) annotate-tests.sh
3940
TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
41+
TINTEROP = $(sort $(wildcard interop/i[0-9][0-9][0-9][0-9]-*.sh))
4042
CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
41-
CHAINLINT = sed -f chainlint.sed
43+
CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
44+
45+
# `test-chainlint` (which is a dependency of `test-lint`, `test` and `prove`)
46+
# checks all tests in all scripts via a single invocation, so tell individual
47+
# scripts not to "chainlint" themselves
48+
CHAINLINTSUPPRESS = GIT_TEST_CHAIN_LINT=0 && export GIT_TEST_CHAIN_LINT &&
4249

4350
all: $(DEFAULT_TEST_TARGET)
4451

4552
test: pre-clean check-chainlint $(TEST_LINT)
46-
$(MAKE) aggregate-results-and-cleanup
53+
$(CHAINLINTSUPPRESS) $(MAKE) aggregate-results-and-cleanup
4754

4855
failed:
4956
@failed=$$(cd '$(TEST_RESULTS_DIRECTORY_SQ)' && \
@@ -52,7 +59,7 @@ failed:
5259
test -z "$$failed" || $(MAKE) $$failed
5360

5461
prove: pre-clean check-chainlint $(TEST_LINT)
55-
@echo "*** prove ***"; $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
62+
@echo "*** prove ***"; $(CHAINLINTSUPPRESS) $(PROVE) --exec '$(TEST_SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
5663
$(MAKE) clean-except-prove-cache
5764

5865
$(T):
@@ -73,13 +80,35 @@ clean-chainlint:
7380

7481
check-chainlint:
7582
@mkdir -p '$(CHAINLINTTMP_SQ)' && \
76-
sed -e '/^# LINT: /d' $(patsubst %,chainlint/%.test,$(CHAINLINTTESTS)) >'$(CHAINLINTTMP_SQ)'/tests && \
77-
sed -e '/^[ ]*$$/d' $(patsubst %,chainlint/%.expect,$(CHAINLINTTESTS)) >'$(CHAINLINTTMP_SQ)'/expect && \
78-
$(CHAINLINT) '$(CHAINLINTTMP_SQ)'/tests | grep -v '^[ ]*$$' >'$(CHAINLINTTMP_SQ)'/actual && \
79-
diff -u '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
83+
for i in $(CHAINLINTTESTS); do \
84+
echo "test_expect_success '$$i' '" && \
85+
sed -e '/^# LINT: /d' chainlint/$$i.test && \
86+
echo "'"; \
87+
done >'$(CHAINLINTTMP_SQ)'/tests && \
88+
{ \
89+
echo "# chainlint: $(CHAINLINTTMP_SQ)/tests" && \
90+
for i in $(CHAINLINTTESTS); do \
91+
echo "# chainlint: $$i" && \
92+
sed -e '/^[ ]*$$/d' chainlint/$$i.expect; \
93+
done \
94+
} >'$(CHAINLINTTMP_SQ)'/expect && \
95+
$(CHAINLINT) --emit-all '$(CHAINLINTTMP_SQ)'/tests | \
96+
grep -v '^[ ]*$$' >'$(CHAINLINTTMP_SQ)'/actual && \
97+
if test -f ../GIT-BUILD-OPTIONS; then \
98+
. ../GIT-BUILD-OPTIONS; \
99+
fi && \
100+
if test -x ../git$$X; then \
101+
DIFFW="../git$$X --no-pager diff -w --no-index"; \
102+
else \
103+
DIFFW="diff -w -u"; \
104+
fi && \
105+
$$DIFFW '$(CHAINLINTTMP_SQ)'/expect '$(CHAINLINTTMP_SQ)'/actual
80106

81107
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \
82108
test-lint-filenames
109+
ifneq ($(GIT_TEST_CHAIN_LINT),0)
110+
test-lint: test-chainlint
111+
endif
83112

84113
test-lint-duplicates:
85114
@dups=`echo $(T) $(TPERF) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
@@ -102,6 +131,9 @@ test-lint-filenames:
102131
test -z "$$bad" || { \
103132
echo >&2 "non-portable file name(s): $$bad"; exit 1; }
104133

134+
test-chainlint:
135+
@$(CHAINLINT) $(T) $(TLIBS) $(TPERF) $(TINTEROP)
136+
105137
aggregate-results-and-cleanup: $(T)
106138
$(MAKE) aggregate-results
107139
$(MAKE) clean
@@ -117,4 +149,5 @@ valgrind:
117149
perf:
118150
$(MAKE) -C perf/ all
119151

120-
.PHONY: pre-clean $(T) aggregate-results clean valgrind perf check-chainlint clean-chainlint
152+
.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
153+
check-chainlint clean-chainlint test-chainlint

t/README

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,6 @@ appropriately before running "make". Short options can be bundled, i.e.
196196
this feature by setting the GIT_TEST_CHAIN_LINT environment
197197
variable to "1" or "0", respectively.
198198

199-
A few test scripts disable some of the more advanced
200-
chain-linting detection in the name of efficiency. You can
201-
override this by setting the GIT_TEST_CHAIN_LINT_HARDER
202-
environment variable to "1".
203-
204199
--stress::
205200
Run the test script repeatedly in multiple parallel jobs until
206201
one of them fails. Useful for reproducing rare failures in

0 commit comments

Comments
 (0)