Serenity Operating System
at master 44 lines 1.5 kB view raw
1/* 2 * Copyright (c) 2022, Ali Mohammad Pur <mpfard@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <LibJS/Runtime/Map.h> 8#include <LibTest/JavaScriptTestRunner.h> 9 10TEST_ROOT("Userland/Applications/Spreadsheet/Tests"); 11 12#ifdef AK_OS_SERENITY 13static constexpr auto s_spreadsheet_runtime_path = "/res/js/Spreadsheet/runtime.js"sv; 14#else 15static constexpr auto s_spreadsheet_runtime_path = "../../../../Base/res/js/Spreadsheet/runtime.js"sv; 16#endif 17 18TESTJS_RUN_FILE_FUNCTION(DeprecatedString const&, JS::Interpreter& interpreter, JS::ExecutionContext& global_execution_context) 19{ 20 auto run_file = [&](StringView name) { 21 auto result = Test::JS::parse_script(name, interpreter.realm()); 22 if (result.is_error()) { 23 warnln("Unable to parse {}", name); 24 warnln("{}", result.error().error.to_deprecated_string()); 25 warnln("{}", result.error().hint); 26 Test::cleanup_and_exit(); 27 } 28 auto script = result.release_value(); 29 30 interpreter.vm().push_execution_context(global_execution_context); 31 MUST(interpreter.run(*script)); 32 interpreter.vm().pop_execution_context(); 33 }; 34 35#ifdef AK_OS_SERENITY 36 run_file(s_spreadsheet_runtime_path); 37#else 38 run_file(LexicalPath::join(Test::JS::g_test_root, s_spreadsheet_runtime_path).string()); 39#endif 40 41 run_file("mock.test-common.js"sv); 42 43 return Test::JS::RunFileHookResult::RunAsNormal; 44}