From 1e8d31a71b1402cbca664a4fa94f2091ff5fed20 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 19 Jun 2020 17:20:53 +0200 Subject: [PATCH 1/2] 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()`. --- test/embedding/embedtest.cc | 1 + test/embedding/test-embedding.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/test/embedding/embedtest.cc b/test/embedding/embedtest.cc index 14e2dfb802d22c..43c0174b6eadbd 100644 --- a/test/embedding/embedtest.cc +++ b/test/embedding/embedtest.cc @@ -93,6 +93,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform, "const publicRequire =" " require('module').createRequire(process.cwd() + '/');" "globalThis.require = publicRequire;" + "globalThis.embedVars = { nön_𝒂scıı: '🏳️‍🌈' };" "require('vm').runInThisContext(process.argv[1]);"); if (loadenv_ret.IsEmpty()) // There has been a JS exception. diff --git a/test/embedding/test-embedding.js b/test/embedding/test-embedding.js index ac50f22e867de1..de39d27a8ef3f0 100644 --- a/test/embedding/test-embedding.js +++ b/test/embedding/test-embedding.js @@ -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_𝒂scıı)']) + .stdout.toString().trim(), + '🏳️‍🌈'); + assert.strictEqual( child_process.spawnSync(binary, ['console.log(42)']) .stdout.toString().trim(), From 1b3212a51dcb099a18c487694477df7ccaf279f1 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 20 Jun 2020 00:03:02 +0200 Subject: [PATCH 2/2] fixup! test: add non-ASCII character embedding test --- test/embedding/embedtest.cc | 2 +- test/embedding/test-embedding.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/embedding/embedtest.cc b/test/embedding/embedtest.cc index 43c0174b6eadbd..a927167ea6a921 100644 --- a/test/embedding/embedtest.cc +++ b/test/embedding/embedtest.cc @@ -93,7 +93,7 @@ int RunNodeInstance(MultiIsolatePlatform* platform, "const publicRequire =" " require('module').createRequire(process.cwd() + '/');" "globalThis.require = publicRequire;" - "globalThis.embedVars = { nön_𝒂scıı: '🏳️‍🌈' };" + "globalThis.embedVars = { nön_ascıı: '🏳️‍🌈' };" "require('vm').runInThisContext(process.argv[1]);"); if (loadenv_ret.IsEmpty()) // There has been a JS exception. diff --git a/test/embedding/test-embedding.js b/test/embedding/test-embedding.js index de39d27a8ef3f0..2fbaaf0ef81a49 100644 --- a/test/embedding/test-embedding.js +++ b/test/embedding/test-embedding.js @@ -19,7 +19,7 @@ assert.strictEqual( '42'); assert.strictEqual( - child_process.spawnSync(binary, ['console.log(embedVars.nön_𝒂scıı)']) + child_process.spawnSync(binary, ['console.log(embedVars.nön_ascıı)']) .stdout.toString().trim(), '🏳️‍🌈');