-
Notifications
You must be signed in to change notification settings - Fork 98
Improve end2end test runner #563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
camillobruni
wants to merge
9
commits into
WebKit:main
Choose a base branch
from
camillobruni:2026-07-14_headless_test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c1ec013
add-headless-option
camillobruni 3bdbe88
fx
camillobruni a18a09b
cleanup
camillobruni 270a132
add-test
camillobruni 54a97ac
merge-main
camillobruni 770b819
fx
camillobruni c5c3a66
add-tests
camillobruni 05c07f6
cleanup
camillobruni 31dd759
merge
camillobruni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,8 +12,9 @@ import "lws-static"; | |
| const ROOT_DIR = path.join(process.cwd(), "./"); | ||
|
|
||
| export default async function serve(port) { | ||
| if (!port) | ||
| if (!port && port !== 0) | ||
| throw new Error("Port is required"); | ||
|
|
||
| const ws = await LocalWebServer.create({ | ||
| port: port, | ||
| hostname: "127.0.0.1", | ||
|
|
@@ -23,30 +24,42 @@ export default async function serve(port) { | |
| logFormat: "dev", | ||
| stack: ["lws-log", "lws-cors", "lws-static", "lws-index"], | ||
| }); | ||
| await verifyStartup(ws, port); | ||
| const actualPort = await verifyStartup(ws); | ||
|
|
||
| process.on("exit", () => ws.server.close()); | ||
|
|
||
| return { | ||
| port: actualPort, | ||
| server: { | ||
| close() { | ||
| ws.server.close(); | ||
| }, | ||
| }, | ||
| close() { | ||
| ws.server.close(); | ||
| }, | ||
| }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the outer |
||
| } | ||
|
|
||
| async function verifyStartup(ws, port) { | ||
| await new Promise((resolve, reject) => { | ||
| ws.server.on("listening", () => { | ||
| async function verifyStartup(ws) { | ||
| return new Promise((resolve, reject) => { | ||
| const onListening = () => { | ||
| const actualPort = ws.server.address().port; | ||
| console.log("Server started:"); | ||
| console.log(` http://localhost:${port}`); | ||
| console.log(` http://localhost:${port}?developerMode`); | ||
| console.log(` http://localhost:${actualPort}`); | ||
| console.log(` http://localhost:${actualPort}?developerMode`); | ||
| console.log(""); | ||
| resolve(); | ||
| }); | ||
| ws.server.on("error", (e) => { | ||
| console.error("Error while starting the server", e); | ||
| reject(e); | ||
| }); | ||
| resolve(actualPort); | ||
| }; | ||
| if (ws.server.listening) { | ||
| onListening(); | ||
| } else { | ||
| ws.server.on("listening", onListening); | ||
| ws.server.on("error", (e) => { | ||
| console.error("Error while starting the server", e); | ||
| reject(e); | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import fs from "node:fs/promises"; | ||
| import path from "node:path"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import { ExperimentalSuites } from "../../suites-experimental/suites.mjs"; | ||
| import { DefaultSuites } from "../../suites/default-suites.mjs"; | ||
|
|
||
| const ROOT_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../"); | ||
|
|
||
| const Suites = [...ExperimentalSuites, ...DefaultSuites]; | ||
|
|
||
| describe("resources", () => { | ||
| it("should have resources.txt listing only valid files via local filesystem", async function () { | ||
| // validating all resource files can take a bit longer than the default timeout. | ||
| this.timeout(10000); | ||
| const brokenResourcesList = []; | ||
| for (const suite of Suites) { | ||
| if (!suite.resources) | ||
| continue; | ||
| const resourcesPath = path.resolve(ROOT_DIR, suite.resources); | ||
| let text; | ||
| try { | ||
| text = await fs.readFile(resourcesPath, "utf-8"); | ||
| } catch (error) { | ||
| brokenResourcesList.push(`${suite.resources} (for ${suite.name}) [error: ${error.message}]`); | ||
| continue; | ||
| } | ||
|
|
||
| if (text.trim().length === 0) { | ||
| brokenResourcesList.push(`${suite.resources} (for ${suite.name}) [error: resources.txt is empty]`); | ||
| continue; | ||
| } | ||
|
|
||
| const files = text.trim().split("\n"); | ||
| for (const file of files) | ||
| expect(file.trim().length).to.be.greaterThan(0, `Found empty line in resources.txt for ${suite.name}`); | ||
|
|
||
| await Promise.all( | ||
| files.map(async (file) => { | ||
| const cleanFile = file.trim(); | ||
| if (!cleanFile) | ||
| return; | ||
| const filePath = cleanFile.startsWith("/") ? path.join(ROOT_DIR, cleanFile) : path.resolve(path.dirname(resourcesPath), cleanFile); | ||
| try { | ||
| const stat = await fs.stat(filePath); | ||
| if (!stat.isFile()) | ||
| brokenResourcesList.push(`${cleanFile} (listed in ${suite.resources}) [error: not a file]`); | ||
| } catch (error) { | ||
| brokenResourcesList.push(`${cleanFile} (listed in ${suite.resources}) [error: ${error.message}]`); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| if (brokenResourcesList.length > 0) | ||
| throw new Error(`Failed to check the following resources:\n${brokenResourcesList.join("\n")}`); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this change isn't necessary, but I don't mind.