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

fix(cli/tools/test_runner): side-load test modules #11515

Merged

Conversation

caspervonb
Copy link
Contributor

@caspervonb caspervonb commented Jul 25, 2021

This fixes a regression introduced in 1.9 where test modules became main modules.

This is undesirable as it will cause executables to start running when they're guarded with import.meta.main.

We now side load (import) the module being tested in a generated module but still mark it as the main module in places where it could be visible like the inspector (effectively everywhere but the import.meta.main flag).

Closes #11504

@caspervonb caspervonb changed the title fix(cli): side-load test modules fix(cli/tools/test_runner): side-load test modules Jul 25, 2021
This fixes a regression introduced in 1.9 where test modules became main
modules by side loading them in a generated module.
@caspervonb caspervonb force-pushed the fix-cli-side-load-test-modules branch from 48628bf to 0663840 Compare July 25, 2021 17:39
Comment on lines +288 to +294
let test_file = File {
local: test_module.to_file_path().unwrap(),
maybe_types: None,
media_type: MediaType::JavaScript,
source: test_source.clone(),
specifier: test_module.clone(),
};
Copy link
Member

Choose a reason for hiding this comment

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

Will the module still be typechecked if it's JS by default?

Copy link
Contributor Author

@caspervonb caspervonb Jul 25, 2021

Choose a reason for hiding this comment

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

Yeah we don't seem to care if the entry point is JavaScript or not (which is weird, we should but that's why we're talking about no-check by default I suppose).

I made sure to include the Check diagnostic in the test expectations when I hardened them, and there are no failures.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM

@bartlomieju bartlomieju merged commit b2fcd3d into denoland:main Jul 26, 2021
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.

Side load test modules
2 participants