From c2cafd39bcf88d87fa2f8f0bea125b60ce22a095 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 16 Aug 2016 17:13:25 +0200 Subject: t/Makefile: ensure that paths are valid on platforms we care Some pathnames that are okay on ext4 and on HFS+ cannot be checked out on Windows. Tests that want to see operations on such paths on filesystems that support them must do so behind appropriate test prerequisites, and must not include them in the source tree (instead they should create them when they run). Otherwise, the source tree cannot even be checked out. Make sure that double-quotes, asterisk, colon, greater/less-than, question-mark, backslash, tab, vertical-bar, as well as any non-ASCII characters never appear in the pathnames with a new test-lint-* target as part of a `make test`. To that end, we call `git ls-files` (ensuring that the paths are quoted properly), relying on the fact that paths containing non-ASCII characters are quoted within double-quotes. In case that the source code does not actually live in a Git repository (e.g. when extracted from a .zip file), or that the `git` executable cannot be executed, we simply ignore the error for now; In that case, our trusty Continuous Integration will be the last line of defense and catch any problematic file name. Noticed when a topic wanted to add a pathname with '>' in it. A check like this will prevent a similar problems from happening in the future. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- t/Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 't/Makefile') diff --git a/t/Makefile b/t/Makefile index 18e2b28b26..d613935f14 100644 --- a/t/Makefile +++ b/t/Makefile @@ -52,7 +52,8 @@ clean-except-prove-cache: clean: clean-except-prove-cache $(RM) .prove -test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax +test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax \ + test-lint-filenames test-lint-duplicates: @dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \ @@ -67,6 +68,14 @@ test-lint-executable: test-lint-shell-syntax: @'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) +test-lint-filenames: + @# We do *not* pass a glob to ls-files but use grep instead, to catch + @# non-ASCII characters (which are quoted within double-quotes) + @bad="$$(git -c core.quotepath=true ls-files 2>/dev/null | \ + grep '["*:<>?\\|]')"; \ + test -z "$$bad" || { \ + echo >&2 "non-portable file name(s): $$bad"; exit 1; } + aggregate-results-and-cleanup: $(T) $(MAKE) aggregate-results $(MAKE) clean -- cgit v1.2.3