Skip to content

Truly independent web browser

test-web: Produce forward slashes in reports on Windows

Zaggy10240670ca81935b
diff --git a/Tests/LibWeb/test-web/Collection.cpp b/Tests/LibWeb/test-web/Collection.cpp
index 822da849ebb..149a4eeb728 100644
--- a/Tests/LibWeb/test-web/Collection.cpp
+++ b/Tests/LibWeb/test-web/Collection.cpp
@@ -22,6 +22,12 @@ bool is_valid_test_name(StringView test_name)
return any_of(valid_test_file_suffixes, [&](auto suffix) { return test_name.ends_with(suffix); });
}
+static ByteString test_relative_path(Application const& app, StringView input_path)
+{
+ LexicalPath relative_path { LexicalPath::relative_path(input_path, app.test_root_path).release_value() };
+ return ByteString::join('/', relative_path.parts_view());
+}
+
ErrorOr<void> collect_crash_tests(Application const& app, Vector<Test>& tests, StringView path, StringView trail)
{
Core::DirIterator it(ByteString::formatted("{}/{}", path, trail), Core::DirIterator::Flags::SkipDots);
@@ -36,7 +42,7 @@ ErrorOr<void> collect_crash_tests(Application const& app, Vector<Test>& tests, S
if (!is_valid_test_name(name))
continue;
- auto relative_path = LexicalPath::relative_path(input_path, app.test_root_path).release_value();
+ auto relative_path = test_relative_path(app, input_path);
tests.append({ TestMode::Crash, input_path, {}, relative_path, relative_path });
}
@@ -60,7 +66,7 @@ ErrorOr<void> collect_dump_tests(Application const& app, Vector<Test>& tests, St
continue;
auto expectation_path = ByteString::formatted("{}/expected/{}/{}.txt", path, trail, LexicalPath::title(name));
- auto relative_path = LexicalPath::relative_path(input_path, app.test_root_path).release_value();
+ auto relative_path = test_relative_path(app, input_path);
tests.append({ mode, input_path, move(expectation_path), relative_path, relative_path });
}
@@ -82,7 +88,7 @@ ErrorOr<void> collect_ref_tests(Application const& app, Vector<Test>& tests, Str
if (!is_valid_test_name(name))
continue;
- auto relative_path = LexicalPath::relative_path(input_path, app.test_root_path).release_value();
+ auto relative_path = test_relative_path(app, input_path);
tests.append({ TestMode::Ref, input_path, {}, relative_path, relative_path });
}
@@ -127,7 +133,7 @@ ErrorOr<void> collect_screenshot_tests(Application const& app, Vector<Test>& tes
continue;
auto expectation_path = screenshot_expectation_path(path, trail, name);
- auto relative_path = LexicalPath::relative_path(input_path, app.test_root_path).release_value();
+ auto relative_path = test_relative_path(app, input_path);
tests.append({ TestMode::Screenshot, input_path, move(expectation_path), relative_path, relative_path });
}
diff --git a/Tests/LibWeb/test-web/main.cpp b/Tests/LibWeb/test-web/main.cpp
index 6906c142779..60135e031a4 100644
--- a/Tests/LibWeb/test-web/main.cpp
+++ b/Tests/LibWeb/test-web/main.cpp
@@ -1108,11 +1108,9 @@ static ErrorOr<int> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePix
"*/wpt-import/common/*"sv,
"*/wpt-import/images/*"sv,
};
- auto normalize_path = [](ByteString const& path) { return path.replace("\\"sv, "/"sv); };
- auto const test_input_path = normalize_path(test.input_path);
- auto const test_relative_path = normalize_path(test.relative_path);
+ auto const test_input_path = test.input_path.replace("\\"sv, "/"sv);
bool is_support_file = any_of(support_file_patterns, [&](auto pattern) { return test_input_path.matches(pattern); });
- bool match_glob = any_of(app.test_globs, [&](auto const& glob) { return test_relative_path.matches(glob, CaseSensitivity::CaseSensitive); });
+ bool match_glob = any_of(app.test_globs, [&](auto const& glob) { return test.relative_path.matches(glob, CaseSensitivity::CaseSensitive); });
return is_support_file || !match_glob;
});
@@ -1157,7 +1155,7 @@ static ErrorOr<int> run_tests(Core::AnonymousBuffer const& theme, Web::DevicePix
Test test = base_test;
test.run_index = run_index;
test.total_runs = app.repeat_count;
- test.safe_relative_path = LexicalPath::join(ByteString::formatted("run-{}", run_index), test.safe_relative_path).string();
+ test.safe_relative_path = ByteString::formatted("run-{}/{}", run_index, test.safe_relative_path);
tests.append(move(test));
}
}