summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2015-08-18 21:22:57 -0700
committerRuss Allbery <eagle@eyrie.org>2015-08-18 21:22:57 -0700
commit475b4022411c005fc9e3c652de1c80f10773dc44 (patch)
tree626f01434836e1afba822779182f40030e5eda72
parent6f901fbc55deb5eb4187fa0e69ec366249d53d49 (diff)
Further rra-c-util 5.8 and C TAP Harness 3.4 updates
Sneak in a few more things: a Test::RRA::Automake fix for removing relative directories, and fixes to C TAP Harness for test lists containing no tests.
-rw-r--r--NEWS2
-rw-r--r--tests/runtests.c40
-rw-r--r--tests/tap/basic.c1
-rw-r--r--tests/tap/perl/Test/RRA/Automake.pm10
4 files changed, 40 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index 83503a3..63898f9 100644
--- a/NEWS
+++ b/NEWS
@@ -11,7 +11,7 @@ krb5-sync 3.1 (unreleased)
* Use calloc or reallocarray instead of malloc.
* Fix compilation with a C++ compiler.
- Update to C TAP Harness 3.3:
+ Update to C TAP Harness 3.4:
* Display verbose test results with -v or C_TAP_VERBOSE.
* Reopen standard input to /dev/null when running a test list.
diff --git a/tests/runtests.c b/tests/runtests.c
index 45e51c8..42a73ea 100644
--- a/tests/runtests.c
+++ b/tests/runtests.c
@@ -3,9 +3,9 @@
*
* Usage:
*
- * runtests [-b <build-dir>] [-s <source-dir>] -l <test-list>
- * runtests [-b <build-dir>] [-s <source-dir>] <test> [<test> ...]
- * runtests -o [-b <build-dir>] [-s <source-dir>] <test>
+ * runtests [-hv] [-b <build-dir>] [-s <source-dir>] -l <test-list>
+ * runtests [-hv] [-b <build-dir>] [-s <source-dir>] <test> [<test> ...]
+ * runtests -o [-h] [-b <build-dir>] [-s <source-dir>] <test>
*
* In the first case, expects a list of executables located in the given file,
* one line per executable. For each one, runs it as part of a test suite,
@@ -54,6 +54,10 @@
* directories. These paths can also be set with the -b and -s command-line
* options, which will override anything set at build time.
*
+ * If the -v option is given, or the C_TAP_VERBOSE environment variable is set,
+ * display the full output of each test as it runs rather than showing a
+ * summary of the results of each test.
+ *
* Any bug reports, bug fixes, and improvements are very much welcome and
* should be sent to the e-mail address below. This program is part of C TAP
* Harness <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
@@ -202,16 +206,18 @@ struct testlist {
* split into variables to satisfy the pedantic ISO C90 limit on strings.
*/
static const char usage_message[] = "\
-Usage: %s [-b <build-dir>] [-s <source-dir>] <test> ...\n\
- %s [-b <build-dir>] [-s <source-dir>] -l <test-list>\n\
- %s -o [-b <build-dir>] [-s <source-dir>] <test>\n\
-\n%s";
-static const char usage_extra[] = "\
+Usage: %s [-hv] [-b <build-dir>] [-s <source-dir>] <test> ...\n\
+ %s [-hv] [-b <build-dir>] [-s <source-dir>] -l <test-list>\n\
+ %s -o [-h] [-b <build-dir>] [-s <source-dir>] <test>\n\
+\n\
Options:\n\
-b <build-dir> Set the build directory to <build-dir>\n\
+%s";
+static const char usage_extra[] = "\
-l <list> Take the list of tests to run from <test-list>\n\
-o Run a single test rather than a list of tests\n\
-s <source-dir> Set the source directory to <source-dir>\n\
+ -v Show the full output of each test\n\
\n\
runtests normally runs each test listed on the command line. With the -l\n\
option, it instead runs every test listed in a file. With the -o option,\n\
@@ -1198,7 +1204,8 @@ find_test(const char *name, const char *source, const char *build)
/*
* Read a list of tests from a file, returning the list of tests as a struct
- * testlist. Reports an error to standard error and exits if the list of
+ * testlist, or NULL if there were no tests (such as a file containing only
+ * comments). Reports an error to standard error and exits if the list of
* tests cannot be read.
*/
static struct testlist *
@@ -1252,6 +1259,12 @@ read_test_list(const char *filename)
}
fclose(file);
+ /* If there were no tests, current is still NULL. */
+ if (current == NULL) {
+ free(listhead);
+ return NULL;
+ }
+
/* Return the results. */
return listhead;
}
@@ -1260,7 +1273,8 @@ read_test_list(const char *filename)
/*
* Build a list of tests from command line arguments. Takes the argv and argc
* representing the command line arguments and returns a newly allocated test
- * list. The caller is responsible for freeing.
+ * list, or NULL if there were no tests. The caller is responsible for
+ * freeing.
*/
static struct testlist *
build_test_list(char *argv[], int argc)
@@ -1285,6 +1299,12 @@ build_test_list(char *argv[], int argc)
current->ts->file = xstrdup(argv[i]);
}
+ /* If there were no tests, current is still NULL. */
+ if (current == NULL) {
+ free(listhead);
+ return NULL;
+ }
+
/* Return the results. */
return listhead;
}
diff --git a/tests/tap/basic.c b/tests/tap/basic.c
index 0b8be8f..4f8be04 100644
--- a/tests/tap/basic.c
+++ b/tests/tap/basic.c
@@ -36,7 +36,6 @@
* DEALINGS IN THE SOFTWARE.
*/
-#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
diff --git a/tests/tap/perl/Test/RRA/Automake.pm b/tests/tap/perl/Test/RRA/Automake.pm
index 1a7fa93..0dc570a 100644
--- a/tests/tap/perl/Test/RRA/Automake.pm
+++ b/tests/tap/perl/Test/RRA/Automake.pm
@@ -101,7 +101,15 @@ sub automake_setup {
my ($vol, $dirs) = File::Spec->splitpath($start, 1);
my @dirs = File::Spec->splitdir($dirs);
pop(@dirs);
- if ($dirs[-1] eq File::Spec->updir) {
+
+ # Simplify relative paths at the end of the directory.
+ my $ups = 0;
+ my $i = $#dirs;
+ while ($i > 2 && $dirs[$i] eq File::Spec->updir) {
+ $ups++;
+ $i--;
+ }
+ for (1 .. $ups) {
pop(@dirs);
pop(@dirs);
}