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

Add regression test for relative imports in tests under lib #2147

Merged
merged 6 commits into from
Dec 5, 2023

Conversation

jakemac53
Copy link
Contributor

Validates the issue listed in #2142.

Skipped for now since it fails in all configurations.

@jakemac53 jakemac53 requested a review from natebosch December 5, 2023 16:52
Copy link
Member

@natebosch natebosch left a comment

Choose a reason for hiding this comment

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

LGTM without the ../lib import version.

Fixes #2142

When a compiler is reading imports it's possible for a relative file
import and absolute package import to the same library to get treated as
separate libraries. The VM works around this in the case of a `main`
under `lib/` by checking when the entrypoint, and only the entrypoint,
could be referenced with a `package:` URI so that further relative URIs
resolved from that point are consistently treated as `package:` URIs.

Use the same workaround for bootstrap files. Add an `absoluteUri`
utility in `test_core` which prefers `package:` URIs when feasible, and
falls back to absolute file URIs otherwise. When this initial import
uses a `package:` URI it will make the subsequent relative imports
correctly resolve as `package:` URIs.

Add `async` and `await` as necessary since we're currently using the
async APIs to read the package config.
@natebosch
Copy link
Member

Oops, I meant to push a new branch and open a PR to pull into this branch, I hadn't intended to push on this branch. Sorry @jakemac53 !

@jakemac53
Copy link
Contributor Author

Oops, I meant to push a new branch and open a PR to pull into this branch, I hadn't intended to push on this branch. Sorry @jakemac53 !

No worries, should I revert or want to land that together with the test?

@natebosch
Copy link
Member

No worries, should I revert or want to land that together with the test?

I reverted it on this branch. I think we should go ahead and land the test and then handle the fix in a separate PR.

@jakemac53 jakemac53 merged commit 6e7e4fa into master Dec 5, 2023
@jakemac53 jakemac53 deleted the relative-import-test branch December 5, 2023 21:55
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.

2 participants