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

feat(es/testing): Parse test code as a Program instead of a Module #9623

Merged
merged 24 commits into from
Oct 8, 2024

Conversation

levi-nz
Copy link
Contributor

@levi-nz levi-nz commented Oct 8, 2024

Description:
This PR addresses the issue described in #8713

BREAKING CHANGE:
Will break unit tests that use fold_module/visit_module/visit_mut_module if the visitor is intended to work for both modules and scripts instead of using fold_program/visit_program/visit_mut_program.

When creating visitors, you should use fold_program/visit_program/visit_mut_program if you simply want to visit the top-level node.

When creating tests, the input source code will be parsed using parse_program by default. If you need to parse it as a Module, you can use module: Some(true) in FixtureTestConfig (or with test!(module, ..)), which will parse it as a Program::Module, or Some(false) for Program::Script. None will use parse_program (parse_program will auto-detect the underlying type).

Related issue (if exists):

@levi-nz levi-nz requested review from a team as code owners October 8, 2024 03:44
Copy link

changeset-bot bot commented Oct 8, 2024

🦋 Changeset detected

Latest commit: 4e5d77c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@levi-nz levi-nz marked this pull request as draft October 8, 2024 03:46
@levi-nz
Copy link
Contributor Author

levi-nz commented Oct 8, 2024

Also, this removes _ok_if_code_is_eq parameter because it wasn't used or referenced anywhere.

@levi-nz levi-nz marked this pull request as ready for review October 8, 2024 04:41
@levi-nz
Copy link
Contributor Author

levi-nz commented Oct 8, 2024

Should be good to go now. CI should pass (I hope).

@levi-nz
Copy link
Contributor Author

levi-nz commented Oct 8, 2024

Also exec_tr and compare_stdout do not have this new feature. It seems like these functions are only used for modules and changing them messed some of the tests up.

@kdy1 kdy1 added this to the Planned milestone Oct 8, 2024
@kdy1 kdy1 merged commit bfea322 into swc-project:main Oct 8, 2024
24 checks passed
Copy link

codspeed-hq bot commented Oct 8, 2024

CodSpeed Performance Report

Merging #9623 will not alter performance

Comparing levi-nz:issue-8713 (4e5d77c) with main (f625035)

Summary

✅ 194 untouched benchmarks

@kdy1 kdy1 modified the milestones: Planned, v1.7.33 Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants