mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWasm: Take call arguments and results on registers if possible
This commit is contained in:
committed by
Ali Mohammad Pur
parent
b89ecfc6bc
commit
be9d8288ef
Notes:
github-actions[bot]
2026-02-06 10:45:34 +00:00
Author: https://github.com/alimpfard Commit: https://github.com/LadybirdBrowser/ladybird/commit/be9d8288ef0 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7477 Reviewed-by: https://github.com/Hendiadyoin1
@@ -177,6 +177,10 @@ public:
|
||||
}
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual ~TestRunnerGlobalObject() override = default;
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(report_test);
|
||||
|
||||
Function<void(String, JS::Value)> on_test_reported;
|
||||
};
|
||||
|
||||
inline void TestRunnerGlobalObject::initialize(JS::Realm& realm)
|
||||
@@ -184,6 +188,7 @@ inline void TestRunnerGlobalObject::initialize(JS::Realm& realm)
|
||||
Base::initialize(realm);
|
||||
|
||||
define_direct_property("global"_utf16_fly_string, this, JS::Attribute::Enumerable);
|
||||
define_native_function(realm, "__reportTest__"_utf16, report_test, 2, JS::default_attributes);
|
||||
for (auto& entry : s_exposed_global_functions) {
|
||||
define_native_function(
|
||||
realm,
|
||||
@@ -195,6 +200,19 @@ inline void TestRunnerGlobalObject::initialize(JS::Realm& realm)
|
||||
}
|
||||
}
|
||||
|
||||
inline JS_DEFINE_NATIVE_FUNCTION(TestRunnerGlobalObject::report_test)
|
||||
{
|
||||
auto const& self = as<TestRunnerGlobalObject>(vm.get_global_object());
|
||||
if (!self.on_test_reported)
|
||||
return JS::js_undefined();
|
||||
|
||||
auto test_name_value = vm.argument(0);
|
||||
auto test_name = TRY(test_name_value.to_string(vm));
|
||||
auto state_value = vm.argument(1);
|
||||
self.on_test_reported(test_name, state_value);
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
inline ByteBuffer load_entire_file(StringView path)
|
||||
{
|
||||
auto try_load_entire_file = [](StringView const& path) -> ErrorOr<ByteBuffer> {
|
||||
@@ -271,6 +289,34 @@ inline Vector<ByteString> TestRunner::get_test_paths() const
|
||||
return paths;
|
||||
}
|
||||
|
||||
inline void print_test_timings(String test_name, JS::Value state_value)
|
||||
{
|
||||
if (state_value.is_string()) {
|
||||
auto state_string = state_value.as_string().utf8_string();
|
||||
if (state_string == "pass"sv) {
|
||||
print_modifiers({ FG_BOLD });
|
||||
out("Finished: ");
|
||||
print_modifiers({ CLEAR });
|
||||
outln("{} (PASS)", test_name);
|
||||
} else if (state_string == "fail"sv) {
|
||||
print_modifiers({ FG_RED, FG_BOLD });
|
||||
out("Finished: ");
|
||||
print_modifiers({ CLEAR });
|
||||
outln("{} (FAIL)", test_name);
|
||||
} else if (state_string == "xfail"sv) {
|
||||
print_modifiers({ FG_ORANGE, FG_BOLD });
|
||||
out("Finished: ");
|
||||
print_modifiers({ CLEAR });
|
||||
outln("{} (XFAIL)", test_name);
|
||||
} else if (state_string == "start"sv) {
|
||||
print_modifiers({ BG_GREEN, FG_ORANGE });
|
||||
out("Running: ");
|
||||
print_modifiers({ CLEAR });
|
||||
outln("{}", test_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline JSFileResult TestRunner::run_file_test(ByteString const& test_path)
|
||||
{
|
||||
g_currently_running_test = test_path;
|
||||
@@ -284,6 +330,9 @@ inline JSFileResult TestRunner::run_file_test(ByteString const& test_path)
|
||||
[&](JS::Realm& realm_) -> JS::GlobalObject* {
|
||||
realm = &realm_;
|
||||
global_object = realm->create<TestRunnerGlobalObject>(*realm);
|
||||
if (this->needs_timings()) {
|
||||
global_object->on_test_reported = print_test_timings;
|
||||
}
|
||||
return global_object;
|
||||
},
|
||||
nullptr));
|
||||
|
||||
Reference in New Issue
Block a user