Repository navigation
Run Babel's unittests in a custom sandbox. - #5135
Conversation
|
@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. |
e03e5ed to
8cff117
Compare
8cff117 to
a34b5b6
Compare
Current coverage is 89.23% (diff: 96.96%)@@ 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
|
|
Alright they actually pass now. |
|
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); |
There was a problem hiding this comment.
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 😖
There was a problem hiding this comment.
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. |
| const relativeMod = new Module(); | ||
| relativeMod.id = relativeFilename; | ||
| relativeMod.filename = relativeFilename; | ||
| relativeMod.paths = Module._nodeModulePaths(path.dirname(relativeFilename)); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Wait, the top level this in sloppy commonjs is supposed to be the exports? 😱
Per Slack conversations, this will allow us to be more confident that Babel itself isn't accidentally relying on logic polyfilled by
babel-polyfillas it is no longer loaded globally, but rather sandboxed to its own context.