summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEllie Timoney <elliemt83@gmail.com>2015-05-11 11:26:23 (GMT)
committerAndreas Schneider <asn@cryptomilk.org>2015-05-11 11:26:23 (GMT)
commitf6b2efadf805e7ef017ff6afcfdf088023f61e2e (patch)
tree44f239c1c107f9f1b7446ed7b9b3236d8370ba8e
parent12ce9a800c6ff9189c004202f019723405003e1d (diff)
downloadcmocka-f6b2efadf805e7ef017ff6afcfdf088023f61e2e.zip
cmocka-f6b2efadf805e7ef017ff6afcfdf088023f61e2e.tar.gz
cmocka-f6b2efadf805e7ef017ff6afcfdf088023f61e2e.tar.bz2
cmocka: Add subtests for groups using TAP output
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/cmocka.c26
-rw-r--r--tests/CMakeLists.txt5
2 files changed, 23 insertions, 8 deletions
diff --git a/src/cmocka.c b/src/cmocka.c
index c8e612c..40be60a 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -2039,7 +2039,19 @@ static void cmprintf_standard(enum cm_printf_type type,
static void cmprintf_group_start_tap(const size_t num_tests)
{
- print_message("1..%u\n", (unsigned)num_tests);
+ print_message("\t1..%u\n", (unsigned)num_tests);
+}
+
+static void cmprintf_group_finish_tap(const char *group_name,
+ size_t total_executed,
+ size_t total_passed,
+ size_t total_skipped)
+{
+ const char *status = "not ok";
+ if (total_passed + total_skipped == total_executed) {
+ status = "ok";
+ }
+ print_message("%s - %s\n", status, group_name);
}
static void cmprintf_tap(enum cm_printf_type type,
@@ -2051,10 +2063,10 @@ static void cmprintf_tap(enum cm_printf_type type,
case PRINTF_TEST_START:
break;
case PRINTF_TEST_SUCCESS:
- print_message("ok %u - %s\n", (unsigned)test_number, test_name);
+ print_message("\tok %u - %s\n", (unsigned)test_number, test_name);
break;
case PRINTF_TEST_FAILURE:
- print_message("not ok %u - %s\n", (unsigned)test_number, test_name);
+ print_message("\tnot ok %u - %s\n", (unsigned)test_number, test_name);
if (error_message != NULL) {
char *msg;
char *p;
@@ -2073,7 +2085,7 @@ static void cmprintf_tap(enum cm_printf_type type,
p[0] = '\0';
}
- print_message("# %s\n", q);
+ print_message("\t# %s\n", q);
if (p == NULL) {
break;
@@ -2084,10 +2096,10 @@ static void cmprintf_tap(enum cm_printf_type type,
}
break;
case PRINTF_TEST_SKIPPED:
- print_message("not ok %u # SKIP %s\n", (unsigned)test_number, test_name);
+ print_message("\tnot ok %u # SKIP %s\n", (unsigned)test_number, test_name);
break;
case PRINTF_TEST_ERROR:
- print_message("not ok %u - %s %s\n",
+ print_message("\tnot ok %u - %s %s\n",
(unsigned)test_number, test_name, error_message);
break;
}
@@ -2161,7 +2173,9 @@ static void cmprintf_group_finish(const char *group_name,
cm_tests);
break;
case CM_OUTPUT_SUBUNIT:
+ break;
case CM_OUTPUT_TAP:
+ cmprintf_group_finish_tap(group_name, total_executed, total_passed, total_skipped);
break;
case CM_OUTPUT_XML:
cmprintf_group_finish_xml(group_name,
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6c67879..2f985a5 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -123,9 +123,10 @@ set(TEST_OUTPUT_FMTS
xml)
set(test_basics_tap_out
- "^1\\.\\.2[ \n\r]+ok 1 - null_test_success")
+ "^\t1\\.\\.2[ \n\r]+\tok 1 - null_test_success[ \n\r]+\tok 2 - int_test_success[ \n\r]+ok - tests")
set(test_assert_macros_fail_tap_out
- "^1\\.\\.1[ \n\r]+not ok 1 - test_assert_return_code_fail")
+ "^\t1\\.\\.1[ \n\r]+\tnot ok 1 - test_assert_return_code_fail[ \n\r]+\t#[^\n\r]+[\n\r]\t#[^\n\r]+[\n\r]not ok - tests")
+
set(test_skip_tap_out
"not ok 1 # SKIP")
set(test_setup_fail_tap_out