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

Run Babel's unittests in a custom sandbox. #5135

Merged
merged 1 commit into from Jan 17, 2017

Conversation

loganfsmyth
Copy link
Member

Per Slack conversations, this will allow us to be more confident that Babel itself isn't accidentally relying on logic polyfilled by babel-polyfill as it is no longer loaded globally, but rather sandboxed to its own context.

@mention-bot
Copy link

@loganfsmyth, thanks for your PR! By analyzing the history of the files in this pull request, we identified @hzoo, @frantic and @zertosh to be potential reviewers.

@codecov-io
Copy link

codecov-io commented Jan 16, 2017

Current coverage is 89.23% (diff: 96.96%)

Merging #5135 into master will increase coverage by 0.01%

@@             master      #5135   diff @@
==========================================
  Files           203        203          
  Lines          9828       9853    +25   
  Methods        1071       1072     +1   
  Messages          0          0          
  Branches       2616       2622     +6   
==========================================
+ Hits           8768       8792    +24   
- Misses         1060       1061     +1   
  Partials          0          0          

Powered by Codecov. Last update e863790...a34b5b6

@loganfsmyth
Copy link
Member Author

Alright they actually pass now.

Copy link
Member

@xtuc xtuc left a comment

Choose a reason for hiding this comment

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

LGTM 👍. It does not affect the build time so much.

@hzoo hzoo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Jan 16, 2017
@hzoo
Copy link
Member

hzoo commented Jan 16, 2017

I think it's only slow on node 0.10/0.12 but we are dropping anyway.

result = babel.transform(execCode, execOpts);
execCode = result.code;

try {
resultExec = runExec(execOpts, execCode, execDirName);
resultExec = runCodeInTestContext(execCode, execOpts);
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if the test files would (default) export a function / promise / boolean instead of relying on top level return, but fixing this would require refactoring all tests 😖

Copy link
Member

Choose a reason for hiding this comment

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

All internal/non breaking so someone can do it 😄

filename = require.resolve(path.resolve(path.dirname(relativeFilename), id));
} else {
// This code is a gross hack using internal APIs, but we also have the same logic in babel-core
// to resolve presets and plugins, so if this breaks, we'll have even worse issues to deal with.
Copy link
Member

Choose a reason for hiding this comment

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

🙈

const relativeMod = new Module();
relativeMod.id = relativeFilename;
relativeMod.filename = relativeFilename;
relativeMod.paths = Module._nodeModulePaths(path.dirname(relativeFilename));
Copy link
Member

Choose a reason for hiding this comment

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

Ah, for resolving inside node_modules dirs as would be seen by the test file

};

// Expose the test options as "opts", but otherwise run the test in a CommonJS-like environment.
// Note: This isn't doing .call(module.exports, ...) because some of our tests currently
Copy link
Member

Choose a reason for hiding this comment

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

Wait, the top level this in sloppy commonjs is supposed to be the exports? 😱

@hzoo hzoo merged commit c76b8ee into babel:master Jan 17, 2017
@loganfsmyth loganfsmyth deleted the run-sandbox-tests branch February 3, 2017 21:59
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants