[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: make sc_require_test_exit_idiom more generic
From: |
Jim Meyering |
Subject: |
[PATCH] tests: make sc_require_test_exit_idiom more generic |
Date: |
Fri, 19 Jun 2009 14:31:56 +0200 |
I wanted to use this test from vc-dwim, too.
It defines the Exit function in a file not named test-lib.sh.
Here's what I've done to accommodate that.
An alternative is to eliminate the witness file altogether and
to search tests/ (aka, $(dir $(Exit_witness_file))) for a definition of Exit,
e.g., via grep -E '^Exit ?\(\)$'. But that might get a false positive,
and this seems like enough for now:
>From 9663cdb7f4531ecb5f35bf7cf45440d6898749d2 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 19 Jun 2009 14:25:37 +0200
Subject: [PATCH] tests: make sc_require_test_exit_idiom more generic
* top/maint.mk (Exit_witness_file): New overridable variable.
(sc_require_test_exit_idiom): Don't hard-code tests/test-lib.sh.
Relax test for /^Exit \$fail$$/ to just /^Exit ./.
---
top/maint.mk | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/top/maint.mk b/top/maint.mk
index ed9c1aa..ef828d1 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -363,16 +363,19 @@ sc_program_name:
# Require that the final line of each test-lib.sh-using test be this one:
# Exit $fail
# Note: this test requires GNU grep's --label= option.
+Exit_witness_file ?= tests/test-lib.sh
+Exit_base := $(notdir $(Exit_witness_file))
sc_require_test_exit_idiom:
- @if test -f $(srcdir)/tests/test-lib.sh; then \
+ @if test -f $(srcdir)/$(Exit_witness_file); then \
die=0; \
- for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
- tail -n1 $$i | grep '^Exit \$$fail$$' > /dev/null \
+ for i in $$(grep -l -F 'srcdir/$(Exit_base)' \
+ $$($(VC_LIST) tests)); do \
+ tail -n1 $$i | grep '^Exit .' > /dev/null \
&& : || { die=1; echo $$i; } \
done; \
test $$die = 1 && \
{ echo 1>&2 '$(ME): the final line in each of the above is not:'; \
- echo 1>&2 'Exit $$fail'; \
+ echo 1>&2 'Exit something'; \
exit 1; } || :; \
fi
--
1.6.3.2.416.g04d0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] tests: make sc_require_test_exit_idiom more generic,
Jim Meyering <=