Skip to content

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

Merged
hzoo merged 1 commit into
babel:masterfrom
loganfsmyth:run-sandbox-tests
Jan 17, 2017
Merged

hzoo merged 1 commit into
babel:masterfrom
loganfsmyth:run-sandbox-tests

Conversation

@loganfsmyth

Copy link
Copy Markdown
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
Copy Markdown

@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

codecov-io commented Jan 16, 2017 •

Copy link
Copy Markdown

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
Copy Markdown
Member Author

Alright they actually pass now.

@xtuc xtuc left a comment •

Copy link
Copy Markdown
Member

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

hzoo commented Jan 16, 2017

Copy link
Copy Markdown
Member

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


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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

6 participants