-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib,repl: ignore non-canBeRequiredByUsers built-in
e.g. `wasi` under no `--experimental-wasi-unstable-preview1` flag shouldn't be pre-required. PR-URL: #39942 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Zijian Liu <[email protected]>
- Loading branch information
Showing
4 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const cp = require('child_process'); | ||
|
||
function runREPLWithAdditionalFlags(flags) { | ||
// Use -i to force node into interactive mode, despite stdout not being a TTY | ||
const args = ['-i'].concat(flags); | ||
const ret = cp.execFileSync(process.execPath, args, { | ||
input: 'require(\'events\');\nrequire(\'wasi\');', | ||
encoding: 'utf8', | ||
}); | ||
return ret; | ||
} | ||
|
||
// Run REPL in normal mode. | ||
let stdout = runREPLWithAdditionalFlags([]); | ||
assert.match(stdout, /\[Function: EventEmitter\] {/); | ||
assert.match( | ||
stdout, | ||
/Uncaught Error: Cannot find module 'wasi'[\w\W]+- <repl>\n/); | ||
|
||
// Run REPL with '--experimental-wasi-unstable-preview1' | ||
stdout = runREPLWithAdditionalFlags([ | ||
'--experimental-wasi-unstable-preview1', | ||
]); | ||
assert.match(stdout, /\[Function: EventEmitter\] {/); | ||
assert.doesNotMatch( | ||
stdout, | ||
/Uncaught Error: Cannot find module 'wasi'[\w\W]+- <repl>\n/); | ||
assert.match(stdout, /{ WASI: \[class WASI\] }/); |