1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

test-js: Don't keep a pointer to a temporary String's characters

This was only an issue in the Lagom build.
This commit is contained in:
Andreas Kling 2020-11-26 09:30:56 +01:00
parent 2b78b17926
commit a5e560ee49

View file

@ -705,13 +705,13 @@ int main(int argc, char** argv)
bool print_times = false; bool print_times = false;
bool test262_parser_tests = false; bool test262_parser_tests = false;
const char* test_root = nullptr; const char* specified_test_root = nullptr;
Core::ArgsParser args_parser; Core::ArgsParser args_parser;
args_parser.add_option(print_times, "Show duration of each test", "show-time", 't'); args_parser.add_option(print_times, "Show duration of each test", "show-time", 't');
args_parser.add_option(collect_on_every_allocation, "Collect garbage after every allocation", "collect-often", 'g'); args_parser.add_option(collect_on_every_allocation, "Collect garbage after every allocation", "collect-often", 'g');
args_parser.add_option(test262_parser_tests, "Run test262 parser tests", "test262-parser-tests", 0); args_parser.add_option(test262_parser_tests, "Run test262 parser tests", "test262-parser-tests", 0);
args_parser.add_positional_argument(test_root, "Tests root directory", "path", Core::ArgsParser::Required::No); args_parser.add_positional_argument(specified_test_root, "Tests root directory", "path", Core::ArgsParser::Required::No);
args_parser.parse(argc, argv); args_parser.parse(argc, argv);
if (test262_parser_tests) { if (test262_parser_tests) {
@ -719,7 +719,7 @@ int main(int argc, char** argv)
fprintf(stderr, "--collect-often and --test262-parser-tests options must not be used together\n"); fprintf(stderr, "--collect-often and --test262-parser-tests options must not be used together\n");
return 1; return 1;
} }
if (!test_root) { if (!specified_test_root) {
fprintf(stderr, "Test root is required with --test262-parser-tests\n"); fprintf(stderr, "Test root is required with --test262-parser-tests\n");
return 1; return 1;
} }
@ -729,7 +729,9 @@ int main(int argc, char** argv)
DebugLogStream::set_enabled(false); DebugLogStream::set_enabled(false);
} }
if (!test_root) { String test_root;
if (!specified_test_root) {
#ifdef __serenity__ #ifdef __serenity__
test_root = "/home/anon/js-tests"; test_root = "/home/anon/js-tests";
#else #else
@ -738,11 +740,11 @@ int main(int argc, char** argv)
printf("No test root given, test-js requires the SERENITY_ROOT environment variable to be set"); printf("No test root given, test-js requires the SERENITY_ROOT environment variable to be set");
return 1; return 1;
} }
test_root = String::formatted("{}/Libraries/LibJS/Tests", serenity_root).characters(); test_root = String::formatted("{}/Libraries/LibJS/Tests", serenity_root);
#endif #endif
} }
if (!Core::File::is_directory(test_root)) { if (!Core::File::is_directory(test_root)) {
fprintf(stderr, "Test root is not a directory: %s\n", test_root); warnln("Test root is not a directory: {}", test_root);
return 1; return 1;
} }