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

Refactor makeTestResults function to use a stack for traversal #14760

Merged
merged 5 commits into from
Dec 27, 2023
Merged

Refactor makeTestResults function to use a stack for traversal #14760

merged 5 commits into from
Dec 27, 2023

Conversation

mbelsky
Copy link
Contributor

@mbelsky mbelsky commented Dec 15, 2023

Summary

It fixes #14759

Test plan

All existing tests must pass

Copy link

linux-foundation-easycla bot commented Dec 15, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Dec 15, 2023

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1c008a2
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/658c7319506e2c00086eb854
😎 Deploy Preview https://deploy-preview-14760--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

thanks!

could you include a test and a changelog entry?

@mbelsky
Copy link
Contributor Author

mbelsky commented Dec 27, 2023

@SimenB thank you for review, I've just added a unit test. Here as an example how the test fails with the current implementation:

Failed test output
 FAIL  packages/jest-circus/src/__tests__/utils.test.ts
  ✕ does not thrown a stack overflow exception (3391 ms)

  ● does not thrown a stack overflow exception

    Command failed with exit code 1: node /private/var/folders/hg/0p1p7xx91x3bf6j2jc47rf6m0000gp/T/76b8add5a46335ec6384215a9ba62432
    /Users/mbelsky/gh/jest/packages/jest-circus/src/utils.ts:323
              testResults.push(...makeTestResults(child));
                          ^

    RangeError: Maximum call stack size exceeded

One issue I noticed: the new unit test is running for 5 seconds and that's quite slow. Do you think there is a more optimal way to test it?

@mbelsky mbelsky requested a review from SimenB December 27, 2023 14:55
@SimenB
Copy link
Member

SimenB commented Dec 27, 2023

Thanks! Could you add the missing copyright header? You can add the minimal one found in other files 🙂

CHANGELOG.md Outdated
@@ -44,6 +44,7 @@
- [**BREAKING**] Changes `testPathPattern` configuration option to `testPathPatterns`, which now takes a list of patterns instead of the regex.
- [**BREAKING**] `--testPathPattern` is now `--testPathPatterns`
- `[jest-reporters, jest-runner]` Unhandled errors without stack get correctly logged to console ([#14619](https://github.com/jestjs/jest/pull/14619))
- `[jest-circus]` Replace recursive `makeTestResults` implementation with iterative one ([#14760](https://github.com/jestjs/jest/pull/14760))
Copy link
Member

Choose a reason for hiding this comment

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

Could you put this alphabetically?

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've put it higher and hope it's the right place 😅

@mbelsky
Copy link
Contributor Author

mbelsky commented Dec 27, 2023

Thanks! Could you add the missing copyright header? You can add the minimal one found in other files 🙂

sure, it's there now!

@mbelsky mbelsky requested a review from SimenB December 27, 2023 18:10
@SimenB
Copy link
Member

SimenB commented Dec 27, 2023

One issue I noticed: the new unit test is running for 5 seconds and that's quite slow. Do you think there is a more optimal way to test it?

I'm not sure - unless it does a lot of work, the test doesn't prove we don't end up with a SO. So I think it's fine 👍

Copy link
Member

Choose a reason for hiding this comment

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

oooh, wait, I don't want a file that's almost 1M lines 😅 can we do expect(stdout.split('\n')).toHaveLength(100_000); or whatever the expectation is?

Copy link
Contributor Author

@mbelsky mbelsky Dec 27, 2023

Choose a reason for hiding this comment

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

yeah, I wasn't sure what approach is better here for this scenario 😅 Updated, thank you!

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

Thanks!

@SimenB SimenB merged commit 6604b37 into jestjs:main Dec 27, 2023
73 checks passed
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: makeTestResults fails with Maximum call stack size exceeded exception
2 participants