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

tests(smoke): convert to single LH run per test #12818

Merged
merged 3 commits into from
Jul 22, 2021
Merged

Conversation

brendankenny
Copy link
Member

part 1/2 of #11950. Wanted to get in these simplifications before FR started appearing in the smoke tests :)

As discussed in #11950, this flattens the smokehouse testDefn format so there's only a single expectations object per smoke test (instead of an array of expectations objects). When both PRs have landed, this means e.g. yarn smoke dbw will only do a single lighthouse run and assert its results, simplifying the process of re-running a single test, improving the test expectation files, and simplifying smokehouse itself quite a bit without all the nesting and logging only when a whole test id is complete, etc.

This PR is only the changes to smokehouse itself, not the expectation files. We need to provide backwards compatibility for the old format because e.g. pubAds uses our smokehouse test format, so that makes for an easy split point in the change (if the backwards compatibility works for our test files, it'll work for them too :). The second PR will be much more bike sheddy, so stay tuned if that's your thing.

This PR:

  • at runtime, converts smoke testDefns in the old format to the new flattened format (using 'offline-0', 'offline-1', 'offline-2', etc for IDs of testDefns created from the array of expectations)
  • makes the CLI do substring checking for picking smoke tests. This will allow e.g. yarn smoke lantern to still select all the lantern tests when wanting to run lantern-xhr, lantern-fetch, etc (and for now makes it so it still works with lantern-0, lantern-1, etc)
  • simplifies smokehouse.js. We get to skip the middle step of runTestDefns -> runTestDefn -> runTest now, and the grouped logging and etc is more straightforward.

@brendankenny brendankenny requested a review from a team as a code owner July 21, 2021 23:15
@brendankenny brendankenny requested review from adamraine and removed request for a team July 21, 2021 23:15
@google-cla google-cla bot added the cla: yes label Jul 21, 2021
Copy link
Member

@adamraine adamraine left a comment

Choose a reason for hiding this comment

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

Overall LGTM

*/
function updateTestDefnFormat(allTestDefns) {
const expandedTestDefns = allTestDefns.map(testDefn => {
if (!Array.isArray(testDefn.expectations)) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: flip case to use positive condition

// Include all tests that *include* requested id.
// e.g. a requested 'pwa' will match 'pwa-airhorner', 'pwa-caltrain', etc
const isRequested = requestedIds.some(requestedId => test.id.includes(requestedId));
return invertMatch !== isRequested;
Copy link
Member

Choose a reason for hiding this comment

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

Since we're not trying to fit this on one line anymore, it could be more explicit.

Suggested change
return invertMatch !== isRequested;
if (invertMatch) isRequested = !isRequested;
return isRequested;

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we're not trying to fit this on one line anymore, it could be more explicit.

I like it

if (result) bufferedConsole.write(result.log);

// If there's not an assertion report, not much detail to share but a failure.
if (report) bufferedConsole.write(report.log);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (report) bufferedConsole.write(report.log);

Copy link
Member Author

@brendankenny brendankenny Jul 22, 2021

Choose a reason for hiding this comment

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

not sure why this suggestion? report and result too similar looking maybe?

(I was actually thinking of renaming them because they are a little hard to differentiate by name, but didn't want to add to the churn. If this is n=2 confusing, happy to rename now :)

edit: or is it just the comment should be lower/changed? This code was structured slightly differently before with the explicit failure block, but I retained the comment

Copy link
Member

@adamraine adamraine Jul 22, 2021

Choose a reason for hiding this comment

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

Wow I can't read haha. I thought L162 was a duplicate of L159.

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

Successfully merging this pull request may close these issues.

3 participants