mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
test262-runner: Attempt to resolve harness for test262 automatically
This makes it easier to use the runner directly.
This commit is contained in:
parent
ca5b91f9cc
commit
e4f3c8bf00
1 changed files with 22 additions and 5 deletions
|
@ -29,6 +29,7 @@ static String s_current_test = "";
|
||||||
static bool s_use_bytecode = false;
|
static bool s_use_bytecode = false;
|
||||||
static bool s_parse_only = false;
|
static bool s_parse_only = false;
|
||||||
static String s_harness_file_directory;
|
static String s_harness_file_directory;
|
||||||
|
static bool s_automatic_harness_detection_mode = false;
|
||||||
|
|
||||||
enum class NegativePhase {
|
enum class NegativePhase {
|
||||||
ParseOrEarly,
|
ParseOrEarly,
|
||||||
|
@ -501,6 +502,18 @@ static bool verify_test(Result<void, TestError>& result, TestMetadata const& met
|
||||||
return error.phase == metadata.phase && error.type == metadata.type;
|
return error.phase == metadata.phase && error.type == metadata.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool extract_harness_directory(String const& test_file_path)
|
||||||
|
{
|
||||||
|
auto test_directory_index = test_file_path.find("test/"sv);
|
||||||
|
if (!test_directory_index.has_value()) {
|
||||||
|
warnln("Attempted to find harness directory from test file '{}', but did not find 'test/'", test_file_path);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_harness_file_directory = String::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static FILE* saved_stdout_fd;
|
static FILE* saved_stdout_fd;
|
||||||
static bool g_in_assert = false;
|
static bool g_in_assert = false;
|
||||||
|
|
||||||
|
@ -551,11 +564,8 @@ int main(int argc, char** argv)
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
if (s_harness_file_directory.is_empty()) {
|
if (s_harness_file_directory.is_empty()) {
|
||||||
dbgln("You must specify the harness file directory via --harness-location");
|
s_automatic_harness_detection_mode = true;
|
||||||
return 2;
|
} else if (!s_harness_file_directory.ends_with('/')) {
|
||||||
}
|
|
||||||
|
|
||||||
if (!s_harness_file_directory.ends_with('/')) {
|
|
||||||
s_harness_file_directory = String::formatted("{}/", s_harness_file_directory);
|
s_harness_file_directory = String::formatted("{}/", s_harness_file_directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,6 +648,13 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
s_current_test = path;
|
s_current_test = path;
|
||||||
|
|
||||||
|
if (s_automatic_harness_detection_mode) {
|
||||||
|
if (!extract_harness_directory(path))
|
||||||
|
return 4;
|
||||||
|
s_automatic_harness_detection_mode = false;
|
||||||
|
VERIFY(!s_harness_file_directory.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
auto file = Core::File::construct(path);
|
auto file = Core::File::construct(path);
|
||||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||||
dbgln("Could not open file: {}", path);
|
dbgln("Could not open file: {}", path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue