summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--source/kit_test/test.c69
-rw-r--r--source/test/programs/CMakeLists.txt6
-rw-r--r--source/test/unittests/condition_variable.test.c2
-rw-r--r--source/test/unittests/thread.test.c2
5 files changed, 48 insertions, 33 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 288f5b9..4f04da2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -143,7 +143,7 @@ if(KIT_ENABLE_TESTING)
add_test(
NAME ${KIT_LIBRARY}_unittests
- COMMAND ${KIT_TEST_SUITE})
+ COMMAND ${KIT_TEST_SUITE} --no-carriage-return)
set_tests_properties(
${KIT_LIBRARY}_unittests
PROPERTIES
diff --git a/source/kit_test/test.c b/source/kit_test/test.c
index 0e8ca4b..dea8a23 100644
--- a/source/kit_test/test.c
+++ b/source/kit_test/test.c
@@ -54,16 +54,28 @@ int kit_run_tests(int argc, char **argv) {
int fail_assertion_count = 0;
int total_assertion_count = 0;
int status = 0;
+ int quiet = 0;
int term_color = 1;
+ int carriage_return = 1;
for (int i = 0; i < argc; i++)
if (strcmp("--no-term-color", argv[i]) == 0)
term_color = 0;
+ else if (strcmp("--no-carriage-return", argv[i]) == 0)
+ carriage_return = 0;
+ else if (strcmp("--quiet", argv[i]) == 0)
+ quiet = 1;
+
+ if (quiet)
+ term_color = 0;
for (int i = 0; i < kit_tests_list.size && i < KIT_TESTS_SIZE_LIMIT;
i++) {
color_code(term_color, yellow);
- printf("[ RUN... ] %s ", kit_tests_list.tests[i].test_name);
+ quiet ||
+ printf("[ RUN... ] %s ", kit_tests_list.tests[i].test_name);
+ if (!carriage_return)
+ quiet || printf("\n");
color_code(term_color, white);
struct timespec begin, end;
@@ -75,7 +87,8 @@ int kit_run_tests(int argc, char **argv) {
int duration = (int) (ns_to_ms(end.tv_nsec - begin.tv_nsec) +
sec_to_ms(end.tv_sec - begin.tv_sec));
- printf("\r");
+ if (carriage_return)
+ quiet || printf("\r");
int test_status = 1;
@@ -93,63 +106,67 @@ int kit_run_tests(int argc, char **argv) {
if (test_status == 0) {
color_code(term_color, red);
- printf("[ RUN ] %s\n", kit_tests_list.tests[i].test_name);
- printf("[ FAILED ] %s", kit_tests_list.tests[i].test_name);
+ quiet || printf("[ RUN ] %s\n",
+ kit_tests_list.tests[i].test_name);
+ quiet ||
+ printf("[ FAILED ] %s", kit_tests_list.tests[i].test_name);
color_code(term_color, white);
if (duration > 0)
- printf(" - %d ms", duration);
- printf("\n");
+ quiet || printf(" - %d ms", duration);
+ quiet || printf("\n");
status = 1;
} else {
color_code(term_color, green);
- printf("[ RUN ] %s\n", kit_tests_list.tests[i].test_name);
- printf("[ OK ] %s", kit_tests_list.tests[i].test_name);
+ quiet || printf("[ RUN ] %s\n",
+ kit_tests_list.tests[i].test_name);
+ quiet ||
+ printf("[ OK ] %s", kit_tests_list.tests[i].test_name);
color_code(term_color, white);
if (duration > 0)
- printf(" - %d ms", duration);
- printf("\n");
+ quiet || printf(" - %d ms", duration);
+ quiet || printf("\n");
success_count++;
}
}
- printf("\n%d of %d tests passed.\n", success_count,
- kit_tests_list.size);
+ quiet || printf("\n%d of %d tests passed.\n", success_count,
+ kit_tests_list.size);
- printf("%d of %d assertions passed.\n\n",
- total_assertion_count - fail_assertion_count,
- total_assertion_count);
+ quiet || printf("%d of %d assertions passed.\n\n",
+ total_assertion_count - fail_assertion_count,
+ total_assertion_count);
if (status != 0) {
for (int i = 0;
i < kit_tests_list.size && i < KIT_TESTS_SIZE_LIMIT; i++) {
if (kit_tests_list.tests[i].assertions >
KIT_TEST_ASSERTIONS_LIMIT)
- printf("Too many assertions for \"%s\" in \"%s\"!\n",
- kit_tests_list.tests[i].test_name,
- kit_tests_list.tests[i]
- .file[KIT_TEST_ASSERTIONS_LIMIT - 1]);
+ quiet || printf("Too many assertions for \"%s\" in \"%s\"!\n",
+ kit_tests_list.tests[i].test_name,
+ kit_tests_list.tests[i]
+ .file[KIT_TEST_ASSERTIONS_LIMIT - 1]);
else
for (int j = 0; j < kit_tests_list.tests[i].assertions; j++)
if (!kit_tests_list.tests[i].status[j])
- printf("Assertion on line %d in \"%s\" failed\n",
- kit_tests_list.tests[i].line[j],
- kit_tests_list.tests[i].file[j]);
+ quiet || printf("Assertion on line %d in \"%s\" failed\n",
+ kit_tests_list.tests[i].line[j],
+ kit_tests_list.tests[i].file[j]);
}
- printf("\n");
+ quiet || printf("\n");
}
if (kit_tests_list.size > KIT_TESTS_SIZE_LIMIT) {
- printf("Too many tests!\n\n");
+ quiet || printf("Too many tests!\n\n");
status = 1;
}
if (status == 0) {
color_code(term_color, green);
- printf("OK\n");
+ quiet || printf("OK\n");
} else {
color_code(term_color, red);
- printf("FAILED\n");
+ quiet || printf("FAILED\n");
}
color_code(term_color, white);
diff --git a/source/test/programs/CMakeLists.txt b/source/test/programs/CMakeLists.txt
index e9f8856..24932bd 100644
--- a/source/test/programs/CMakeLists.txt
+++ b/source/test/programs/CMakeLists.txt
@@ -3,7 +3,7 @@ if(KIT_ENABLE_TESTING)
target_link_libraries(too_many_tests ${KIT_TEST_LIBRARY})
add_test(
NAME too_many_tests_test
- COMMAND too_many_tests)
+ COMMAND too_many_tests --quiet)
set_tests_properties(
too_many_tests_test
PROPERTIES
@@ -13,7 +13,7 @@ if(KIT_ENABLE_TESTING)
target_link_libraries(too_many_assertions ${KIT_TEST_LIBRARY})
add_test(
NAME too_many_assertions_test
- COMMAND too_many_assertions)
+ COMMAND too_many_assertions --quiet)
set_tests_properties(
too_many_assertions_test
PROPERTIES
@@ -23,7 +23,7 @@ if(KIT_ENABLE_TESTING)
target_link_libraries(cpp_example ${KIT_TEST_LIBRARY})
add_test(
NAME cpp_example_test
- COMMAND cpp_example)
+ COMMAND cpp_example --quiet)
set_tests_properties(
cpp_example_test
PROPERTIES
diff --git a/source/test/unittests/condition_variable.test.c b/source/test/unittests/condition_variable.test.c
index f354b4c..63b82b4 100644
--- a/source/test/unittests/condition_variable.test.c
+++ b/source/test/unittests/condition_variable.test.c
@@ -32,8 +32,6 @@ static int test_run(void *p) {
}
TEST("condition variable") {
- printf("\n\n%% condition variable\n\n");
-
test_data_t data;
REQUIRE(mtx_init(&data.m, mtx_plain) == thrd_success);
REQUIRE(cnd_init(&data.send) == thrd_success);
diff --git a/source/test/unittests/thread.test.c b/source/test/unittests/thread.test.c
index f60ad18..a797fee 100644
--- a/source/test/unittests/thread.test.c
+++ b/source/test/unittests/thread.test.c
@@ -39,7 +39,7 @@ TEST("thread run") {
TEST("thread stack size") {
thrd_t foo;
- REQUIRE(thrd_create_with_stack(&foo, test_nothing, NULL, 200000) ==
+ REQUIRE(thrd_create_with_stack(&foo, test_nothing, NULL, 30000) ==
thrd_success);
REQUIRE(thrd_join(foo, NULL) == thrd_success);
}