From 21b705ee3270756b36c48cb763113a9a95d765f1 Mon Sep 17 00:00:00 2001 From: sideshowbarker Date: Sat, 2 Nov 2024 14:12:40 +0900 Subject: [PATCH] Documentation: Explain how to import tests using the WPT.sh script --- CONTRIBUTING.md | 2 ++ Documentation/GettingStartedContributing.md | 1 + Documentation/Testing.md | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f5e27808656..a401d1f10e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,8 @@ Note that this also applies to debug logging and other internal strings, as they When possible, please include tests when fixing bugs or adding new features. +If changes you’re making have relevant [Web Platform Tests (WPT)](https://wpt.fyi/) tests — especially if the changes cause Ladybird to pass any WPT tests it hadn’t yet been passing — you should consider [importing those tests into your Ladybird clone](https://github.com/LadybirdBrowser/ladybird/blob/master/Documentation/Testing.md#importing-web-platform-tests), and then commit the imported tests along with your code changes. + ## Code submission policy Nobody is perfect, and sometimes we mess things up. That said, here are some good do's & don'ts to try and stick to: diff --git a/Documentation/GettingStartedContributing.md b/Documentation/GettingStartedContributing.md index ac049562cfa..8ff6e13470a 100644 --- a/Documentation/GettingStartedContributing.md +++ b/Documentation/GettingStartedContributing.md @@ -89,3 +89,4 @@ Make sure your code meets the requirements in the [full contribution guidelines] * Make correctly formatted, atomic commits (building the project at every commit should succeed). * Discuss and resolve any reviews you receive. * Fix CI failures by editing your commits. +* Include tests ([use `Meta/import-wpt-test.py` to import WPT tests](Testing.md#importing-web-platform-tests)) diff --git a/Documentation/Testing.md b/Documentation/Testing.md index 2c503cbec89..a21953d6fca 100644 --- a/Documentation/Testing.md +++ b/Documentation/Testing.md @@ -110,6 +110,17 @@ git checkout my-css-change ./Meta/WPT.sh run --log results.log ``` +### Importing Web Platform Tests + +You can import certain Web Platform Tests (WPT) tests into your Ladybird clone (if they’re tests of type that can be imported — and especially if any code changes you’re making cause Ladybird to pass any WPT tests it hasn’t yet been passing). Here’s how: + +```sh +./Meta/WPT.sh import html/dom/aria-attribute-reflection.html +``` + +That is, you give `./Meta/WPT.sh import` the path part of any `http://wpt.live/` URL for a WPT test you want to import. It will then download both that test and any of its JavaScript scripts, copy those to the `Tests/LibWeb/Text/input/wpt-import` directory, run the test, and then in the `Tests/LibWeb/Text/expected/wpt-import` directory, it will create a file with the expected results from the test. + + ## Writing tests Running `Tests/LibWeb/add_libweb_test.py your-new-test-name` will create a new test HTML file in