summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibTest/CrashTest.cpp
diff options
context:
space:
mode:
authorMichel Hermier <michel.hermier@gmail.com>2021-12-15 09:20:38 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-19 14:22:06 -0800
commitb1b94692e69c6c4f22f0fbace1b9a80d5d3bd304 (patch)
tree7f6d042e0327cd06c45c89a57aa8e9348bf9d5a2 /Userland/Libraries/LibTest/CrashTest.cpp
parent2f8fac3528a46f4d5edb8d166a006287e4f47243 (diff)
downloadserenity-b1b94692e69c6c4f22f0fbace1b9a80d5d3bd304.zip
LibTest: Handle test reporting in the a unique path
Diffstat (limited to 'Userland/Libraries/LibTest/CrashTest.cpp')
-rw-r--r--Userland/Libraries/LibTest/CrashTest.cpp43
1 files changed, 27 insertions, 16 deletions
diff --git a/Userland/Libraries/LibTest/CrashTest.cpp b/Userland/Libraries/LibTest/CrashTest.cpp
index 2610c10c98..c002bec148 100644
--- a/Userland/Libraries/LibTest/CrashTest.cpp
+++ b/Userland/Libraries/LibTest/CrashTest.cpp
@@ -49,28 +49,39 @@ bool Crash::run(RunType run_type)
return do_report(Failure(WEXITSTATUS(status)));
}
if (WIFSIGNALED(status)) {
- outln("\x1B[32mPASS\x1B[0m: Terminated with signal {}", WTERMSIG(status));
- return true;
+ return do_report(WTERMSIG(status));
}
VERIFY_NOT_REACHED();
}
}
-bool Crash::do_report(Failure failure)
+bool Crash::do_report(Report report)
{
- // If we got here something went wrong
- out("\x1B[31mFAIL\x1B[0m: ");
- switch (failure) {
- case Failure::DidNotCrash:
- outln("Did not crash!");
- break;
- case Failure::UnexpectedError:
- outln("Unexpected error!");
- break;
- default:
- VERIFY_NOT_REACHED();
- }
- return false;
+ const bool pass = report.has<int>();
+
+ if (pass)
+ out("\x1B[32mPASS\x1B[0m: ");
+ else
+ out("\x1B[31mFAIL\x1B[0m: ");
+
+ report.visit(
+ [&](const Failure& failure) {
+ switch (failure) {
+ case Failure::DidNotCrash:
+ outln("Did not crash!");
+ break;
+ case Failure::UnexpectedError:
+ outln("Unexpected error!");
+ break;
+ default:
+ VERIFY_NOT_REACHED();
+ }
+ },
+ [&](const int& signal) {
+ outln("Terminated with signal {}", signal);
+ });
+
+ return pass;
}
}