Commit 4169d1cc authored by Mikaël Salson's avatar Mikaël Salson

Tests: Tests fail when never executed

parent 4e85549a
......@@ -8,26 +8,30 @@ using namespace std;
extern int *test_results;
extern int *test_nb_executions;
extern string *test_messages;
#define TAP_DECLARATIONS int *test_results; \
int *test_nb_executions; \
string *test_messages;
#define TAP_MAX_FAILED 20
#define TAP_ADDITIONAL_INFOS ""
#define TAP_START(nb_test) test_results = (int *)calloc(nb_test, sizeof(int)); \
test_nb_executions = (int *) calloc(nb_test, sizeof(int));\
test_messages = new string[nb_test];
#define RECORD_TAP_TEST(id, msg) test_messages[id] = msg;
#define TAP_TEST(test, id, msg) if (test_results[id] <= TAP_MAX_FAILED) { \
#define TAP_TEST(test, id, msg) { test_nb_executions[id]++; \
if (test_results[id] <= TAP_MAX_FAILED) { \
if (! (test)) { \
test_results[id]++; \
cerr << "Test " << #test << " failed (" << __FILE__ << ":" \
<< __LINE__ << "): " << msg << endl; \
cerr << "\tadditional infos: " << TAP_ADDITIONAL_INFOS << endl; \
}}
}}}
#define TAP_END_TEST tap_end_test(__FILE__)
......@@ -39,19 +43,20 @@ inline bool tap_end_test(const char *filename) {
tap_file.open(tap_filename.c_str(), ios_base::out);
tap_file << "1.." << NB_TESTS << endl;
for (int i = 0; i < NB_TESTS; i++) {
if (test_results[i] == 0)
if (test_results[i] == 0 && test_nb_executions[i] > 0)
tap_file << "ok " << i+1;
else {
ok = false;
tap_file << "not ok " << i+1;
}
if (! test_messages[i].empty()) {
tap_file << " - " << test_messages[i];
tap_file << " - " << test_messages[i] << " (executed " << test_nb_executions[i] << " times)";
}
tap_file << endl;
}
tap_file.close();
free(test_results);
free(test_nb_executions);
delete [] test_messages;
return ok;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment