diff options
author | Torsten Bögershausen <tboegi@web.de> | 2013-01-03 00:20:19 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-02 16:06:42 -0800 |
commit | c7ce70ace9794a8f0b4774d803536a7ecdf318de (patch) | |
tree | 984a46565e24ffc9f8ca12c83e31817077abbc0c /t/Makefile | |
parent | Git 1.8.1 (diff) | |
download | tgif-c7ce70ace9794a8f0b4774d803536a7ecdf318de.tar.xz |
test: Add check-non-portable-shell.pl
Add the perl script "check-non-portable-shell.pl" to detect
non-portable shell syntax.
"echo -n" is an example of a shell command working on Linux, but not
on Mac OS X.
These shell commands are checked and reported as error:
- "echo -n" (printf should be used)
- "sed -i" (GNUism; use a temp file instead)
- "declare" (bashism, often used with arrays)
- "which" (unreliable exit status and output; use type instead)
- "test a == b" (bashism for "test a = b")
"make test-lint-shell-syntax" can be used to run only the check.
Helped-By: Jeff King <peff@peff.net>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/Makefile')
-rw-r--r-- | t/Makefile | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/t/Makefile b/t/Makefile index 3025418ff5..a43becba9d 100644 --- a/t/Makefile +++ b/t/Makefile @@ -16,6 +16,7 @@ DEFAULT_TEST_TARGET ?= test # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh)) @@ -43,7 +44,7 @@ clean-except-prove-cache: 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` && \ @@ -55,6 +56,9 @@ test-lint-executable: test -z "$$bad" || { \ echo >&2 "non-executable tests:" $$bad; exit 1; } +test-lint-shell-syntax: + @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) + aggregate-results-and-cleanup: $(T) $(MAKE) aggregate-results $(MAKE) clean @@ -87,7 +91,7 @@ test-results: mkdir -p test-results test-results/git-smoke.tar.gz: test-results - $(PERL_PATH) ./harness \ + '$(PERL_PATH_SQ)' ./harness \ --archive="test-results/git-smoke.tar.gz" \ $(T) |