mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibTest: Handle test reporting in the a unique path
This commit is contained in:
parent
2f8fac3528
commit
b1b94692e6
2 changed files with 30 additions and 17 deletions
|
@ -49,28 +49,39 @@ bool Crash::run(RunType run_type)
|
||||||
return do_report(Failure(WEXITSTATUS(status)));
|
return do_report(Failure(WEXITSTATUS(status)));
|
||||||
}
|
}
|
||||||
if (WIFSIGNALED(status)) {
|
if (WIFSIGNALED(status)) {
|
||||||
outln("\x1B[32mPASS\x1B[0m: Terminated with signal {}", WTERMSIG(status));
|
return do_report(WTERMSIG(status));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Crash::do_report(Failure failure)
|
bool Crash::do_report(Report report)
|
||||||
{
|
{
|
||||||
// If we got here something went wrong
|
const bool pass = report.has<int>();
|
||||||
out("\x1B[31mFAIL\x1B[0m: ");
|
|
||||||
switch (failure) {
|
if (pass)
|
||||||
case Failure::DidNotCrash:
|
out("\x1B[32mPASS\x1B[0m: ");
|
||||||
outln("Did not crash!");
|
else
|
||||||
break;
|
out("\x1B[31mFAIL\x1B[0m: ");
|
||||||
case Failure::UnexpectedError:
|
|
||||||
outln("Unexpected error!");
|
report.visit(
|
||||||
break;
|
[&](const Failure& failure) {
|
||||||
default:
|
switch (failure) {
|
||||||
VERIFY_NOT_REACHED();
|
case Failure::DidNotCrash:
|
||||||
}
|
outln("Did not crash!");
|
||||||
return false;
|
break;
|
||||||
|
case Failure::UnexpectedError:
|
||||||
|
outln("Unexpected error!");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[&](const int& signal) {
|
||||||
|
outln("Terminated with signal {}", signal);
|
||||||
|
});
|
||||||
|
|
||||||
|
return pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
|
#include <AK/Variant.h>
|
||||||
|
|
||||||
namespace Test {
|
namespace Test {
|
||||||
|
|
||||||
|
@ -30,7 +31,8 @@ public:
|
||||||
bool run(RunType run_type = RunType::UsingChildProcess);
|
bool run(RunType run_type = RunType::UsingChildProcess);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool do_report(Failure failure);
|
using Report = Variant<Failure, int>;
|
||||||
|
bool do_report(Report report);
|
||||||
|
|
||||||
String m_type;
|
String m_type;
|
||||||
Function<Crash::Failure()> m_crash_function;
|
Function<Crash::Failure()> m_crash_function;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue