Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions t/.gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
t[0-9][0-9][0-9][0-9]/* -whitespace
/chainlint/*.expect eol=lf -whitespace
/lint-style/*.expect eol=lf -whitespace
/lint-style/*.test eol=lf -whitespace
/t0110/url-* binary
/t3206/* eol=lf
/t3900/*.txt eol=lf
Expand Down
37 changes: 35 additions & 2 deletions t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ TPERF = $(sort $(wildcard perf/p[0-9][0-9][0-9][0-9]-*.sh))
TINTEROP = $(sort $(wildcard interop/i[0-9][0-9][0-9][0-9]-*.sh))
CHAINLINTTESTS = $(sort $(patsubst chainlint/%.test,%,$(wildcard chainlint/*.test)))
CHAINLINT = '$(PERL_PATH_SQ)' chainlint.pl
LINT_STYLE_TESTS = $(sort $(wildcard lint-style/*.test))
UNIT_TEST_SOURCES = $(wildcard unit-tests/t-*.c)
UNIT_TEST_PROGRAMS = $(patsubst unit-tests/%.c,unit-tests/bin/%$(X),$(UNIT_TEST_SOURCES))
UNIT_TEST_PROGRAMS += unit-tests/bin/unit-tests$(X)
Expand Down Expand Up @@ -139,7 +140,7 @@ check-meson:
test-lint: test-lint-duplicates test-lint-executable \
test-lint-filenames
ifneq ($(PERL_PATH),)
test-lint: test-lint-shell-syntax
test-lint: test-lint-shell-syntax test-lint-style check-lint-style check-shell-parser
else
GIT_TEST_CHAIN_LINT = 0
endif
Expand All @@ -160,6 +161,36 @@ test-lint-executable:
test-lint-shell-syntax:
@'$(PERL_PATH_SQ)' check-non-portable-shell.pl $(T) $(THELPERS) $(TPERF)

check-shell-parser:
@'$(PERL_PATH_SQ)' check-shell-parser.pl

TSOURCED = $(sort $(wildcard t[0-9]*/*.sh))

test-lint-style:
@'$(PERL_PATH_SQ)' lint-style.pl $(T) $(THELPERS) $(TPERF) $(TSOURCED)

check-lint-style:
@rc=0; for t in $(LINT_STYLE_TESTS); do \
base=$${t%.test}; \
case $$base in \
*-fix) \
cp "$$t" "$$t.tmp" && \
'$(PERL_PATH_SQ)' lint-style.pl --fix "$$t.tmp" >/dev/null 2>&1; \
fix_rc=$$?; \
if test $$fix_rc != 0; then \
echo "FAIL: $$t (--fix exit code $$fix_rc)"; rc=1; \
elif ! diff -u "$$base.expect" "$$t.tmp"; then \
echo "FAIL: $$t (--fix output)"; rc=1; \
fi; \
rm -f "$$t.tmp" ;; \
*) \
if ! '$(PERL_PATH_SQ)' lint-style.pl "$$t" 2>&1 | \
diff -u "$$base.expect" -; then \
echo "FAIL: $$t"; rc=1; \
fi ;; \
esac; \
done; test $$rc = 0

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)
Expand All @@ -185,7 +216,9 @@ perf:
$(MAKE) -C perf/ all

.PHONY: pre-clean $(T) aggregate-results clean valgrind perf \
check-chainlint clean-chainlint test-chainlint $(UNIT_TESTS)
check-chainlint clean-chainlint test-chainlint \
check-shell-parser \
check-lint-style test-lint-style $(UNIT_TESTS)

.PHONY: libgit-sys-test libgit-rs-test
libgit-sys-test:
Expand Down
21 changes: 21 additions & 0 deletions t/README
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,27 @@ see test-lib-functions.sh for the full list and their options.

Check whether a file has the length it is expected to.

- test_grep [!] [<grep-options>] <pattern> <file>

Check whether <file> contains a line matching <pattern>, or
with '!' that no line matches. Use this instead of bare
'grep <pattern> <file>' in test assertions. On failure,
test_grep prints the contents of <file> for easier debugging,
whereas a bare 'grep' would fail silently.

For negation, pass '!' as the first argument:

test_grep ! "^diff --git" actual

Do not negate by writing '! test_grep', as that suppresses the
diagnostic output.

test_grep should only be used as a test assertion. When grep
is used as a data filter (e.g. 'grep -v "^index" actual >filtered')
or inside a command substitution (e.g. '$(grep -c ...)'), plain
'grep' is the right choice because the exit code is not the
assertion itself.

- test_path_is_file <path>
test_path_is_dir <path>
test_path_is_missing <path>
Expand Down
Loading
Loading