summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-01-20 16:33:20 +0100
committerLukas Fleischer <calcurse@cryptocrack.de>2012-01-21 23:06:32 +0100
commit9cba56ac0ae9d8e6d58b8d5d645dfbca58321e0b (patch)
treeb080290874364dd19245f9af3884b90eea39f47b
parente66e2d4277998094ee58ebd7c9455507df303939 (diff)
downloadcalcurse-9cba56ac0ae9d8e6d58b8d5d645dfbca58321e0b.zip
test/run-test.c: Support negative assertions
Sometimes, we might want to make negative assertions (tests where expected and actual output are expected/known to be different). A test can be marked negative by prefixing it with an exclamation mark ('!'): $ ./run-test !test-negative Running test-negative... ok Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r--test/run-test.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/run-test.c b/test/run-test.c
index 31fda0c..be9f1ce 100644
--- a/test/run-test.c
+++ b/test/run-test.c
@@ -151,7 +151,7 @@ usage (void)
/* Run test with a specific name. */
static int
-run_test (const char *name)
+run_test (const char *name, int expect_failure)
{
char filename[BUFSIZ];
char *arg1[3], *arg2[3];
@@ -210,6 +210,9 @@ run_test (const char *name)
if (child_wait (&pin2, NULL, pid2) != 0)
ret = 0;
+ if (expect_failure)
+ ret = 1 - ret;
+
if (ret == 1)
printf (" ok\n");
else
@@ -233,8 +236,16 @@ main (int argc, char **argv)
for (i = 1; i < argc; i++)
{
- if (!run_test (argv[i]))
- return 1;
+ if (*argv[i] == '!')
+ {
+ if (!run_test (argv[i] + 1, 1))
+ return 1;
+ }
+ else
+ {
+ if (!run_test (argv[i], 0))
+ return 1;
+ }
}
return 0;