Sitelet https://web.archive.org/web/20230219013129im_/https://github.com/nodejs/node/commit/4cd7f5f147
Skip to content
Permalink
Browse files
test: add non-ASCII character embedding test
Add a test that verifies that non-ASCII characters may be used
in the source code provided to `LoadEnvironment()`.

PR-URL: #33972
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax committed Sep 23, 2020
1 parent 9173b09 commit 4cd7f5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
@@ -94,6 +94,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform,
"const publicRequire ="
" require('module').createRequire(process.cwd() + '/');"
"globalThis.require = publicRequire;"
"globalThis.embedVars = { nön_ascıı: '🏳️‍🌈' };"
"require('vm').runInThisContext(process.argv[1]);");

if (loadenv_ret.IsEmpty()) // There has been a JS exception.
@@ -6,12 +6,23 @@ const child_process = require('child_process');
const path = require('path');

common.allowGlobals(global.require);
common.allowGlobals(global.embedVars);
let binary = `out/${common.buildType}/embedtest`;
if (common.isWindows) {
binary += '.exe';
}
binary = path.resolve(__dirname, '..', '..', binary);

assert.strictEqual(
child_process.spawnSync(binary, ['console.log(42)'])
.stdout.toString().trim(),
'42');

assert.strictEqual(
child_process.spawnSync(binary, ['console.log(embedVars.nön_ascıı)'])
.stdout.toString().trim(),
'🏳️‍🌈');

assert.strictEqual(
child_process.spawnSync(binary, ['console.log(42)'])
.stdout.toString().trim(),

0 comments on commit 4cd7f5f

Please sign in to comment.