Tests/LibWeb: Restructure Ref and Screenshot test dirs to match others

Now each test type has the same directories:
- input
- expected
- data

Also, tests can be in subdirectories within ./input.
This commit is contained in:
Sam Atkins 2024-11-05 12:49:08 +00:00 committed by Sam Atkins
commit b7efb61fbe
Notes: github-actions[bot] 2024-11-05 16:45:19 +00:00
360 changed files with 451 additions and 448 deletions

View file

@ -158,7 +158,7 @@ are identical. These are ideal for testing visual effects such as background ima
difficult to recreate the effect in the reference page, (such as for SVG or canvas,) consider using a Screenshot test difficult to recreate the effect in the reference page, (such as for SVG or canvas,) consider using a Screenshot test
instead. instead.
Each Ref test includes a special `<link rel="match" href="reference/my-test-ref.html" />` tag, which the test runner Each Ref test includes a special `<link rel="match" href="../expected/my-test-ref.html" />` tag, which the test runner
uses to locate the reference page. In this way, multiple tests can use the same reference. uses to locate the reference page. In this way, multiple tests can use the same reference.
### Screenshot ### Screenshot
@ -167,5 +167,5 @@ Screenshot tests can be thought of as a subtype of Ref tests, where the referenc
to a screenshot of the expected output. In general, try to avoid using them if a regular Ref test would do, as they are to a screenshot of the expected output. In general, try to avoid using them if a regular Ref test would do, as they are
sensitive to small rendering changes, and won't work on all platforms. sensitive to small rendering changes, and won't work on all platforms.
Like Ref tests, they require a `<link rel="match" href="reference/my-test-ref.html" />` tag to indicate the reference Like Ref tests, they require a `<link rel="match" href="../expected/my-test-ref.html" />` tag to indicate the reference
page to use. page to use.

View file

@ -80,17 +80,20 @@ static ErrorOr<void> collect_dump_tests(Vector<Test>& tests, StringView path, St
return {}; return {};
} }
static ErrorOr<void> collect_ref_tests(Vector<Test>& tests, StringView path) static ErrorOr<void> collect_ref_tests(Vector<Test>& tests, StringView path, StringView trail)
{ {
TRY(Core::Directory::for_each_entry(path, Core::DirIterator::SkipDots, [&](Core::DirectoryEntry const& entry, Core::Directory const&) -> ErrorOr<IterationDecision> { Core::DirIterator it(ByteString::formatted("{}/input/{}", path, trail), Core::DirIterator::Flags::SkipDots);
if (entry.type == Core::DirectoryEntry::Type::Directory) while (it.has_next()) {
return IterationDecision::Continue; auto name = it.next_path();
auto input_path = TRY(FileSystem::real_path(ByteString::formatted("{}/input/{}/{}", path, trail, name)));
if (FileSystem::is_directory(input_path)) {
TRY(collect_ref_tests(tests, path, ByteString::formatted("{}/{}", trail, name)));
continue;
}
auto input_path = TRY(FileSystem::real_path(ByteString::formatted("{}/{}", path, entry.name)));
tests.append({ TestMode::Ref, input_path, {}, {} }); tests.append({ TestMode::Ref, input_path, {}, {} });
}
return IterationDecision::Continue;
}));
return {}; return {};
} }
@ -374,9 +377,9 @@ ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Gfx::IntSize window_
TRY(collect_dump_tests(tests, ByteString::formatted("{}/Layout", app.test_root_path), "."sv, TestMode::Layout)); TRY(collect_dump_tests(tests, ByteString::formatted("{}/Layout", app.test_root_path), "."sv, TestMode::Layout));
TRY(collect_dump_tests(tests, ByteString::formatted("{}/Text", app.test_root_path), "."sv, TestMode::Text)); TRY(collect_dump_tests(tests, ByteString::formatted("{}/Text", app.test_root_path), "."sv, TestMode::Text));
TRY(collect_ref_tests(tests, ByteString::formatted("{}/Ref", app.test_root_path))); TRY(collect_ref_tests(tests, ByteString::formatted("{}/Ref", app.test_root_path), "."sv));
#if !defined(AK_OS_MACOS) #if !defined(AK_OS_MACOS)
TRY(collect_ref_tests(tests, ByteString::formatted("{}/Screenshot", app.test_root_path))); TRY(collect_ref_tests(tests, ByteString::formatted("{}/Screenshot", app.test_root_path), "."sv));
#endif #endif
tests.remove_all_matching([&](auto const& test) { tests.remove_all_matching([&](auto const& test) {

View file

@ -1,4 +0,0 @@
<!doctype html>
<link rel="match" href="reference/body-link-attribute-ref.html" />
<body link="#FF0000">
<a href="about:blank">link

View file

Before

Width:  |  Height:  |  Size: 129 B

After

Width:  |  Height:  |  Size: 129 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 237 B

After

Width:  |  Height:  |  Size: 237 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 94 B

After

Width:  |  Height:  |  Size: 94 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 272 B

Before After
Before After

View file

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<link rel="match" href="reference/anonymous-wrapper-css-visibility-ref.html" /> <link rel="match" href="../expected/anonymous-wrapper-css-visibility-ref.html" />
<style> <style>
body { body {
color: transparent; color: transparent;

View file

@ -6,9 +6,9 @@
display: inline-block; display: inline-block;
min-width: 12px; min-width: 12px;
min-height: 12px; min-height: 12px;
background-image: url("../assets/2x2checkerboard.png"); background-image: url("../data/2x2checkerboard.png");
background-size: calc(max(0.75em, 12px)); background-size: calc(max(0.75em, 12px));
} }
</style> </style>
</head> </head>
<body><span></span><img src="../assets/2x2checkerboard.png"> <body><span></span><img src="../data/2x2checkerboard.png">

View file

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<link rel="match" href="reference/body-link-attribute.html-ref" /> <link rel="match" href="../expected/body-link-attribute.html-ref" />
<style> <style>
a { a {
color: #FF0000; color: #FF0000;

View file

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<link rel="match" href="reference/inline-paintable-inside-translated-container-ref.html" /> <link rel="match" href="../expected/inline-paintable-inside-translated-container-ref.html" />
<style> <style>
body { body {
margin-top: 100px; margin-top: 100px;

View file

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 186 B

Before After
Before After

View file

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<link rel="match" href="reference/outlines-ref.html" /> <link rel="match" href="../expected/outlines-ref.html" />
<style> <style>
.border { .border {
width: 100px; width: 100px;

View file

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<link rel="match" href="reference/overflow-hidden-3-ref.html" /> <link rel="match" href="../expected/overflow-hidden-3-ref.html" />
<style> <style>
.green { .green {
width: 200px; width: 200px;

View file

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<link rel="match" href="reference/overflow-hidden-4-ref.html" /> <link rel="match" href="../expected/overflow-hidden-4-ref.html" />
<style> <style>
* { * {
outline: black solid 1px; outline: black solid 1px;

View file

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<head> <head>
<link rel="match" href="reference/overflow-hidden-5-ref.html" /> <link rel="match" href="../expected/overflow-hidden-5-ref.html" />
<style type="text/css"> <style type="text/css">
body { body {
margin: 0; margin: 0;

View file

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<link rel="match" href="reference/overflow-hidden-6-ref.html" /> <link rel="match" href="../expected/overflow-hidden-6-ref.html" />
<style> <style>
.box { .box {
width: 100px; width: 100px;

View file

@ -1,5 +1,5 @@
<html> <html>
<link rel="match" href="reference/positioned-elements-in-scroll-container-ref.html" /> <link rel="match" href="../expected/positioned-elements-in-scroll-container-ref.html" />
<style> <style>
* { * {
margin: 0; margin: 0;

View file

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<link rel="match" href="reference/resolve-paint-only-properties-after-layout-ref.html" /> <link rel="match" href="../expected/resolve-paint-only-properties-after-layout-ref.html" />
<style> <style>
#box { #box {
width: 100px; width: 100px;

View file

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<link rel="match" href="reference/scrollable-content-inside-fixed-position-box-ref.html" /> <link rel="match" href="../expected/scrollable-content-inside-fixed-position-box-ref.html" />
<style> <style>
* { * {
scrollbar-width: none; scrollbar-width: none;

View file

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 175 B

Before After
Before After

Some files were not shown because too many files have changed in this diff Show more