test-web: Add updates from test-js
These should definitely be deduplicated at some point.
This commit is contained in:
parent
5877d6713c
commit
bedd15c340
Notes:
sideshowbarker
2024-07-19 03:15:58 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/bedd15c3403 Pull-request: https://github.com/SerenityOS/serenity/pull/3266 Issue: https://github.com/SerenityOS/serenity/issues/3240
1 changed files with 14 additions and 4 deletions
|
@ -59,6 +59,7 @@ enum class TestResult {
|
|||
struct JSTest {
|
||||
String name;
|
||||
TestResult result;
|
||||
String details;
|
||||
};
|
||||
|
||||
struct JSSuite {
|
||||
|
@ -308,7 +309,9 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
if (!m_js_test_common) {
|
||||
auto result = parse_file(String::format("%s/test-common.js", m_js_test_root.characters()));
|
||||
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();
|
||||
}
|
||||
m_js_test_common = result.value();
|
||||
|
@ -317,7 +320,9 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
if (!m_web_test_common) {
|
||||
auto result = parse_file(String::format("%s/test-common.js", m_web_test_root.characters()));
|
||||
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();
|
||||
}
|
||||
m_web_test_common = result.value();
|
||||
|
@ -390,7 +395,7 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
ASSERT(suite_value.is_object());
|
||||
|
||||
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.as_object().has("result"));
|
||||
|
@ -405,6 +410,10 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
test.result = TestResult::Fail;
|
||||
m_counts.tests_failed++;
|
||||
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 {
|
||||
test.result = TestResult::Skip;
|
||||
if (suite.most_severe_test_result == TestResult::Pass)
|
||||
|
@ -590,7 +599,8 @@ void TestRunner::print_file_result(const JSFileResult& file_result) const
|
|||
printf(" Test: ");
|
||||
if (test.result == TestResult::Fail) {
|
||||
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 {
|
||||
print_modifiers({ CLEAR, FG_ORANGE });
|
||||
printf("%s (skipped)\n", test.name.characters());
|
||||
|
|
Loading…
Add table
Reference in a new issue