Browse Source

test-js: Run with the JavaScript bytecode VM by default

The AST interpreter is still available behind a new `--ast` flag.

We switch to testing with bytecode in the big run-tests battery on
SerenityOS. Lagom CI continues running both AST and BC.
Andreas Kling 2 năm trước cách đây
mục cha
commit
96d5a1edb0

+ 3 - 3
Meta/Lagom/CMakeLists.txt

@@ -667,10 +667,10 @@ if (BUILD_LAGOM)
         set_tests_properties(JS PROPERTIES ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT})
         set_tests_properties(JS PROPERTIES ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT})
 
 
         add_test(
         add_test(
-            NAME JS-Bytecode
-            COMMAND test-js -b --show-progress=false
+            NAME JS-AST
+            COMMAND test-js --ast --show-progress=false
         )
         )
-        set_tests_properties(JS-Bytecode PROPERTIES ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT})
+        set_tests_properties(JS-AST PROPERTIES ENVIRONMENT SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT})
 
 
         # Extra tests from Tests/LibJS
         # Extra tests from Tests/LibJS
         lagom_test(../../Tests/LibJS/test-invalid-unicode-js.cpp LIBS LibJS)
         lagom_test(../../Tests/LibJS/test-invalid-unicode-js.cpp LIBS LibJS)

+ 5 - 5
Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp

@@ -93,7 +93,7 @@ int main(int argc, char** argv)
 #endif
 #endif
     bool print_json = false;
     bool print_json = false;
     bool per_file = false;
     bool per_file = false;
-    bool use_bytecode = false;
+    bool use_ast_interpreter = false;
     StringView specified_test_root;
     StringView specified_test_root;
     DeprecatedString common_path;
     DeprecatedString common_path;
     DeprecatedString test_glob;
     DeprecatedString test_glob;
@@ -119,7 +119,7 @@ int main(int argc, char** argv)
     args_parser.add_option(print_json, "Show results as JSON", "json", 'j');
     args_parser.add_option(print_json, "Show results as JSON", "json", 'j');
     args_parser.add_option(per_file, "Show detailed per-file results as JSON (implies -j)", "per-file", 0);
     args_parser.add_option(per_file, "Show detailed per-file results as JSON (implies -j)", "per-file", 0);
     args_parser.add_option(g_collect_on_every_allocation, "Collect garbage after every allocation", "collect-often", 'g');
     args_parser.add_option(g_collect_on_every_allocation, "Collect garbage after every allocation", "collect-often", 'g');
-    args_parser.add_option(use_bytecode, "Use the bytecode interpreter", "run-bytecode", 'b');
+    args_parser.add_option(use_ast_interpreter, "Enable JavaScript AST interpreter (deprecated)", "ast", 0);
     args_parser.add_option(JS::Bytecode::g_dump_bytecode, "Dump the bytecode", "dump-bytecode", 'd');
     args_parser.add_option(JS::Bytecode::g_dump_bytecode, "Dump the bytecode", "dump-bytecode", 'd');
     args_parser.add_option(test_glob, "Only run tests matching the given glob", "filter", 'f', "glob");
     args_parser.add_option(test_glob, "Only run tests matching the given glob", "filter", 'f', "glob");
     for (auto& entry : g_extra_args)
     for (auto& entry : g_extra_args)
@@ -137,12 +137,12 @@ int main(int argc, char** argv)
         AK::set_debug_enabled(false);
         AK::set_debug_enabled(false);
     }
     }
 
 
-    if (JS::Bytecode::g_dump_bytecode && !use_bytecode) {
-        warnln("--dump-bytecode can only be used when --run-bytecode is specified.");
+    if (JS::Bytecode::g_dump_bytecode && use_ast_interpreter) {
+        warnln("--dump-bytecode can not be used when --ast is specified.");
         return 1;
         return 1;
     }
     }
 
 
-    JS::Bytecode::Interpreter::set_enabled(use_bytecode);
+    JS::Bytecode::Interpreter::set_enabled(!use_ast_interpreter);
 
 
     DeprecatedString test_root;
     DeprecatedString test_root;