Browse Source

Showing all failures in tests for easier debugging.

David Piuva 10 months ago
parent
commit
4e6ebfceb3
1 changed files with 12 additions and 4 deletions
  1. 12 4
      Source/test/testTools.h

+ 12 - 4
Source/test/testTools.h

@@ -3,6 +3,7 @@
 
 
 // TODO: Make it faster to crawl source by only including what is needed by the test.
 // TODO: Make it faster to crawl source by only including what is needed by the test.
 #include "../DFPSR/includeFramework.h"
 #include "../DFPSR/includeFramework.h"
+#include <cstdlib>
 #include <csignal>
 #include <csignal>
 
 
 using namespace dsr;
 using namespace dsr;
@@ -73,22 +74,27 @@ static void handleArguments(const List<String> &args) {
 
 
 static thread_local String testName = U"Uninitialized test\n";
 static thread_local String testName = U"Uninitialized test\n";
 static thread_local String stateName = U"New thread\n";
 static thread_local String stateName = U"New thread\n";
+static bool failed = false;
 
 
 #define START_TEST(NAME) \
 #define START_TEST(NAME) \
 DSR_MAIN_CALLER(dsrMain) \
 DSR_MAIN_CALLER(dsrMain) \
 void dsrMain(List<String> args) { \
 void dsrMain(List<String> args) { \
 	testName = #NAME; \
 	testName = #NAME; \
 	stateName = U"While Assigning message handler"; \
 	stateName = U"While Assigning message handler"; \
-	std::signal(SIGSEGV, [](int signal) { throwError(U"Segmentation fault from ", testName, U"! ", stateName); }); \
+	std::signal(SIGSEGV, [](int signal) { failed = true; throwError(U"Segmentation fault from ", testName, U"! ", stateName); }); \
 	string_assignMessageHandler(&messageHandler); \
 	string_assignMessageHandler(&messageHandler); \
 	stateName = U"While handling arguments\n"; \
 	stateName = U"While handling arguments\n"; \
 	handleArguments(args); \
 	handleArguments(args); \
 	stateName = U"Test start\n"; \
 	stateName = U"Test start\n"; \
-	printText(U"Running test \"", #NAME, "\": ");
+	printText(U"Running test \"", #NAME, "\":\n ");
 
 
 #define END_TEST \
 #define END_TEST \
 	printText(U" (done)\n"); \
 	printText(U" (done)\n"); \
 	stateName = U"After test end\n"; \
 	stateName = U"After test end\n"; \
+	if (failed) { \
+		heap_terminatingApplication(); \
+		exit(1); \
+	} \
 }
 }
 
 
 // These can be used instead of ASSERT_CRASH to handle multiple template arguments that are not enclosed within ().
 // These can be used instead of ASSERT_CRASH to handle multiple template arguments that are not enclosed within ().
@@ -112,13 +118,14 @@ void dsrMain(List<String> args) { \
 	if (CONDITION) { \
 	if (CONDITION) { \
 		printText(U"*"); \
 		printText(U"*"); \
 	} else { \
 	} else { \
-		throwError( \
+		printText( \
 			U"\n\n", \
 			U"\n\n", \
 			U"_______________________________ FAIL _______________________________\n", \
 			U"_______________________________ FAIL _______________________________\n", \
 			U"\n", \
 			U"\n", \
 			U"Failed assertion!\nCondition: ", #CONDITION, U"\n", \
 			U"Failed assertion!\nCondition: ", #CONDITION, U"\n", \
 			U"____________________________________________________________________\n" \
 			U"____________________________________________________________________\n" \
 		); \
 		); \
+		failed = true; \
 	} \
 	} \
 }
 }
 
 
@@ -130,7 +137,7 @@ void dsrMain(List<String> args) { \
 	if (OP(lhs, rhs)) { \
 	if (OP(lhs, rhs)) { \
 		printText(U"*"); \
 		printText(U"*"); \
 	} else { \
 	} else { \
-		throwError( \
+		printText( \
 			U"\n\n", \
 			U"\n\n", \
 			U"_______________________________ FAIL _______________________________\n", \
 			U"_______________________________ FAIL _______________________________\n", \
 			U"\n", \
 			U"\n", \
@@ -138,6 +145,7 @@ void dsrMain(List<String> args) { \
 			lhs, " ", OP_NAME, " ", rhs, U" is false.\n", \
 			lhs, " ", OP_NAME, " ", rhs, U" is false.\n", \
 			U"____________________________________________________________________\n" \
 			U"____________________________________________________________________\n" \
 		); \
 		); \
+		failed = true; \
 	} \
 	} \
 }
 }
 #define ASSERT_EQUAL(A, B) ASSERT_COMP(A, B, OP_EQUALS, "==")
 #define ASSERT_EQUAL(A, B) ASSERT_COMP(A, B, OP_EQUALS, "==")