Skip to content
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

Runner Cleanup: SuiteRunner & TestRunner classes #452

Merged
merged 14 commits into from
Nov 15, 2024

Conversation

flashdesignory
Copy link
Contributor

  • move SuiteRunner class into a separate file
  • create a new TestRunner class, which a remote workload could consume in the future
  • rename _runTestAndRecordResults to TestRunner.runTest()
  • create class methods for functions used in the runSync & measureAsync functions

@bgrins
Copy link
Contributor

bgrins commented Nov 14, 2024

I like the direction here - would like @julienw to review the change if possible.

@flashdesignory to confirm - the big picture idea here is that remote tests will (eventually) consume resources/test-runner.mjs themselves, and it will grow functionality to manage communication back and forth with the suite (postMessage etc)?

@flashdesignory
Copy link
Contributor Author

@flashdesignory to confirm - the big picture idea here is that remote tests will (eventually) consume resources/test-runner.mjs themselves, and it will grow functionality to manage communication back and forth with the suite (postMessage etc)?

remote tests would use the test-runner class, that's correct 😄.
postMessage communication will happen on a higher level in the workloads, not on a test-runner level.

resources/test-runner.mjs Outdated Show resolved Hide resolved
resources/test-runner.mjs Outdated Show resolved Hide resolved
resources/test-runner.mjs Outdated Show resolved Hide resolved
let asyncTime;
const runSync = () => {
this._runWarmupSuite();
syncTime = this._measureSyncTime(syncStartLabel, syncEndLabel);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is harder to follow with nested function calls. We should go back to having all the code here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to find a good way to be able to reuse as much as possible for remote workloads.
If I keep everything in one function, I'll end up overriding the whole function, when I might just need to change one line in one nested function call.

With this, I should be able to create a new class that extends TestRunner, but only overrides one method, which is more targeted and introduces less CLs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is the line that needs to be changed for remote workloads?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some examples, that are slightly different for remote workloads:

this._test.run(this._page);
The remote workloads don't use a page object to wrap elements.
Also, if we opt into async workloads, we might want to await the run function.

_forceLayout()
It works, although I won't use or pass in a frame reference.

These are just some examples

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both examples can work as is (even if page and frame are not passed in), but I still feel that smaller methods might be easier to follow and reuse.

This shouldn't be a blocker though and if I'm the only one feeling this way, I can certainly change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should make it more of a copy/paste for this PR and then follow up with refactors? I think it'll be easier to say one way or the other with (a) the change unbundled from the file move and (b) when we have a remote implementation to consider.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, doing the split as a follow up seems like a good idea here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good - i'll fix it up!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

resources/test-runner.mjs Outdated Show resolved Hide resolved
@flashdesignory flashdesignory requested a review from rniwa November 15, 2024 00:13
Copy link
Contributor

@bgrins bgrins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go ahead and approve in place of Julien with the simplified change in place

@flashdesignory flashdesignory merged commit 67bc21f into WebKit:main Nov 15, 2024
4 checks passed
@flashdesignory flashdesignory deleted the cleanup/runner branch November 15, 2024 18:42
@julienw
Copy link
Contributor

julienw commented Nov 18, 2024

FTR looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants