Re-visiting an old thread:
On 01/24/2014 06:44 PM, Pádraig Brady wrote:
On 01/24/2014 10:39 PM, Bernhard Voelker wrote:
<...>
Thus said, instead of adding a script, I'd favor a new make target
which can search all test cases and run them - incl. (very-)expensive
if necessary. Something like
make check-some T=cp
Yes I agree.
Attached is a patch that adds a 'makefile' target to test a program.
Examples:
make check-prog T=sort
make check-very-expensive-prog T=tail
Regards,
- Assaf
>From 1f33b3e52f8ca7fe2b9bc95ace7c921d0eb033f0 Mon Sep 17 00:00:00 2001
From: Assaf Gordon <assafgor...@gmail.com>
Date: Thu, 31 Jul 2014 06:54:45 +0300
Subject: [PATCH] maint: add makefile shortcut to test one program
* Makefile.am: add 'check-prog', 'check-expensive-prog',
'check-very-expensive-prog' targets to quickly find and run tests
relating to a specific program
* HACKING: document new options.
Typical usage, run all 'tail' tests:
make check-prog T=tail
Discussed here:
http://lists.gnu.org/archive/html/coreutils/2014-01/msg00110.html
---
HACKING | 16 ++++++++++++++++
Makefile.am | 16 ++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/HACKING b/HACKING
index 393a623..9acc3cf 100644
--- a/HACKING
+++ b/HACKING
@@ -434,6 +434,22 @@ and moving into existing blocks. This avoids making unnecessary
work for translators.
+Testing
+========
+To run all existing tests for a specific program (e.g. 'seq'), run:
+
+ make check-prog T=seq
+
+Similarly, to run expensive or very expensive tests, run:
+
+ make check-expensive-prog T=tail
+ make check-very-expensive-prog T=sort
+
+T=[PROG] takes a basic regular expression, allowing:
+
+ make check-prog T='sha.*'
+
+
Add tests
==========
Nearly every significant change must be accompanied by a test suite
diff --git a/Makefile.am b/Makefile.am
index fb4af27..e238904 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -85,6 +85,22 @@ check-expensive:
check-very-expensive:
$(MAKE) check-expensive RUN_VERY_EXPENSIVE_TESTS=yes
+# Shortcut to run all tests of a specific program
+# Typical usage:
+# make check-prog PROG=sort
+check-prog:
+ $(AM_V_GEN)( test -n "$$T" || \
+ { echo missing T=[program] parameter >&2 ; exit 1 ; } ; \
+ TESTS=$$(find ./tests/ \( -name '*.sh' -o -name '*.pl' \) -print | \
+ grep -w -- "$$T" | paste -s -d' ' -) ; \
+ test -z "$$TESTS" && \
+ { echo no tests found for program "$$T" >&2 ; exit 1 ; } ; \
+ $(MAKE) check TESTS="$$TESTS" SUBDIRS=. VERBOSE=yes )
+check-expensive-prog:
+ $(MAKE) check-prog RUN_EXPENSIVE_TESTS=yes
+check-very-expensive-prog:
+ $(MAKE) check-expensive-prog RUN_VERY_EXPENSIVE_TESTS=yes
+
# Just prior to distribution, ...
# transform the automake-generated rule that runs 'rm -f rm'.
# On some systems, that command would fail with a diagnostic like
--
1.9.1