mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
test-web: Add updates from test-js
These should definitely be deduplicated at some point.
This commit is contained in:
parent
5877d6713c
commit
bedd15c340
1 changed files with 14 additions and 4 deletions
|
@ -59,6 +59,7 @@ enum class TestResult {
|
||||||
struct JSTest {
|
struct JSTest {
|
||||||
String name;
|
String name;
|
||||||
TestResult result;
|
TestResult result;
|
||||||
|
String details;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct JSSuite {
|
struct JSSuite {
|
||||||
|
@ -308,7 +309,9 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
||||||
if (!m_js_test_common) {
|
if (!m_js_test_common) {
|
||||||
auto result = parse_file(String::format("%s/test-common.js", m_js_test_root.characters()));
|
auto result = parse_file(String::format("%s/test-common.js", m_js_test_root.characters()));
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
printf("Unable to parse %s/test-common.js", m_js_test_root.characters());
|
printf("Unable to parse %s/test-common.js\n", m_js_test_root.characters());
|
||||||
|
printf("%s\n", result.error().error.to_string().characters());
|
||||||
|
printf("%s\n", result.error().hint.characters());
|
||||||
cleanup_and_exit();
|
cleanup_and_exit();
|
||||||
}
|
}
|
||||||
m_js_test_common = result.value();
|
m_js_test_common = result.value();
|
||||||
|
@ -317,7 +320,9 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
||||||
if (!m_web_test_common) {
|
if (!m_web_test_common) {
|
||||||
auto result = parse_file(String::format("%s/test-common.js", m_web_test_root.characters()));
|
auto result = parse_file(String::format("%s/test-common.js", m_web_test_root.characters()));
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
printf("Unable to parse %s/test-common.js", m_web_test_root.characters());
|
printf("Unable to parse %s/test-common.js\n", m_web_test_root.characters());
|
||||||
|
printf("%s\n", result.error().error.to_string().characters());
|
||||||
|
printf("%s\n", result.error().hint.characters());
|
||||||
cleanup_and_exit();
|
cleanup_and_exit();
|
||||||
}
|
}
|
||||||
m_web_test_common = result.value();
|
m_web_test_common = result.value();
|
||||||
|
@ -390,7 +395,7 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
||||||
ASSERT(suite_value.is_object());
|
ASSERT(suite_value.is_object());
|
||||||
|
|
||||||
suite_value.as_object().for_each_member([&](const String& test_name, const JsonValue& test_value) {
|
suite_value.as_object().for_each_member([&](const String& test_name, const JsonValue& test_value) {
|
||||||
JSTest test { test_name, TestResult::Fail };
|
JSTest test { test_name, TestResult::Fail, "" };
|
||||||
|
|
||||||
ASSERT(test_value.is_object());
|
ASSERT(test_value.is_object());
|
||||||
ASSERT(test_value.as_object().has("result"));
|
ASSERT(test_value.as_object().has("result"));
|
||||||
|
@ -405,6 +410,10 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
||||||
test.result = TestResult::Fail;
|
test.result = TestResult::Fail;
|
||||||
m_counts.tests_failed++;
|
m_counts.tests_failed++;
|
||||||
suite.most_severe_test_result = TestResult::Fail;
|
suite.most_severe_test_result = TestResult::Fail;
|
||||||
|
ASSERT(test_value.as_object().has("details"));
|
||||||
|
auto details = test_value.as_object().get("details");
|
||||||
|
ASSERT(result.is_string());
|
||||||
|
test.details = details.as_string();
|
||||||
} else {
|
} else {
|
||||||
test.result = TestResult::Skip;
|
test.result = TestResult::Skip;
|
||||||
if (suite.most_severe_test_result == TestResult::Pass)
|
if (suite.most_severe_test_result == TestResult::Pass)
|
||||||
|
@ -590,7 +599,8 @@ void TestRunner::print_file_result(const JSFileResult& file_result) const
|
||||||
printf(" Test: ");
|
printf(" Test: ");
|
||||||
if (test.result == TestResult::Fail) {
|
if (test.result == TestResult::Fail) {
|
||||||
print_modifiers({ CLEAR, FG_RED });
|
print_modifiers({ CLEAR, FG_RED });
|
||||||
printf("%s (failed)\n", test.name.characters());
|
printf("%s (failed):\n", test.name.characters());
|
||||||
|
printf(" %s\n", test.details.characters());
|
||||||
} else {
|
} else {
|
||||||
print_modifiers({ CLEAR, FG_ORANGE });
|
print_modifiers({ CLEAR, FG_ORANGE });
|
||||||
printf("%s (skipped)\n", test.name.characters());
|
printf("%s (skipped)\n", test.name.characters());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue