* [PATCH] tests: add some script lint checks
@ 2010-04-12 6:52 Jeff King
2010-04-12 7:41 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Jeff King @ 2010-04-12 6:52 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Johannes Sixt, git
There are some common but minor errors we tend to make in
writing test scripts:
1. Scripts are left non-executable. This is not usually
noticed immediately because "make test" does not need
the bit, but it is a matter of git policy to make them
executable (and is a slight convenience when running
individual scripts).
2. Two scripts are allocated the same number. Usually this
happens on separate branches, and the problem only
comes about during a merge. But since there is no
textual conflict, the merger would have to be very
observant to notice.
This is also a minor error, but can make GIT_SKIP_TESTS
ambiguous.
This patch introduces a "test-lint" target which checks
both. It is not invoked by default. You can invoke it as
"make test-lint", or you can make it a prerequisite of
running the tests by specifying "TEST_LINT = test-lint" in
your config.mak or on the command line.
Signed-off-by: Jeff King <peff@peff.net>
---
The dup half is based on Johannes' earlier patch.
Obviously this can help submitters avoid dumb mistakes, so I plan to
turn it on for myself. As maintainer, Junio, you might want to run at
least with TEST_LINT = test-lint-duplicate, since you can then catch
duplicates introduced by merges and fix them up as part of the merge.
t/Makefile | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/t/Makefile b/t/Makefile
index 25c559b..40ae67c 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -16,7 +16,7 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
TSVN = $(wildcard t91[0-9][0-9]-*.sh)
-all: pre-clean
+all: pre-clean $(TEST_LINT)
$(MAKE) aggregate-results-and-cleanup
$(T):
@@ -30,6 +30,18 @@ clean:
$(RM) t????/cvsroot/CVSROOT/?*
$(RM) -r valgrind/bin
+test-lint: test-lint-duplicates test-lint-executable
+
+test-lint-duplicates:
+ @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \
+ test -z "$$dups" || { \
+ echo >&2 "duplicate test numbers:" $$dups; exit 1; }
+
+test-lint-executable:
+ @bad=`for i in $(T); do test -x "$$i" || echo $$i; done` && \
+ test -z "$$bad" || { \
+ echo >&2 "non-executable tests:" $$bad; exit 1; }
+
aggregate-results-and-cleanup: $(T)
$(MAKE) aggregate-results
$(MAKE) clean
--
1.7.1.rc1.245.g808fe
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tests: add some script lint checks
2010-04-12 6:52 [PATCH] tests: add some script lint checks Jeff King
@ 2010-04-12 7:41 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2010-04-12 7:41 UTC (permalink / raw)
To: Jeff King; +Cc: Johannes Sixt, git
Jeff King <peff@peff.net> writes:
> As maintainer, Junio, you might want to run at
> least with TEST_LINT = test-lint-duplicate, since you can then catch
> duplicates introduced by merges and fix them up as part of the merge.
Thanks. They are caught by pre-applypatch from 'todo' these days. I
should also perhaps check for the executable bit there.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-12 7:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-12 6:52 [PATCH] tests: add some script lint checks Jeff King
2010-04-12 7:41 ` Junio C Hamano
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.