summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2016-04-19 11:42:26 -0400
committerFedor Indutny <fedor@indutny.com>2016-04-20 12:34:44 -0400
commite1cf634a0bd0cae2b54c60c8f19fc29079bdc309 (patch)
tree29801dfb232646c2bd9607ee855e3443788b997d /test
parent5f0fcd6245a28761b0e8a565e99bca5ae2b5432e (diff)
downloadandroid-node-v8-e1cf634a0bd0cae2b54c60c8f19fc29079bdc309.tar.gz
android-node-v8-e1cf634a0bd0cae2b54c60c8f19fc29079bdc309.tar.bz2
android-node-v8-e1cf634a0bd0cae2b54c60c8f19fc29079bdc309.zip
test: spawn new processes in vm-cached-data
V8 may start caching scripts from the first run soon. Preventively execute scripts in another process to ensure no test failures due to an update in the future. See: #6258 PR-URL: https://github.com/nodejs/node/pull/6280 Reviewed-By: Jochen Eisinger <jochen@chromium.org> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-vm-cached-data.js35
1 files changed, 26 insertions, 9 deletions
diff --git a/test/parallel/test-vm-cached-data.js b/test/parallel/test-vm-cached-data.js
index 924f082684..2ad1abe0d8 100644
--- a/test/parallel/test-vm-cached-data.js
+++ b/test/parallel/test-vm-cached-data.js
@@ -2,19 +2,38 @@
require('../common');
const assert = require('assert');
const vm = require('vm');
+const spawnSync = require('child_process').spawnSync;
const Buffer = require('buffer').Buffer;
function getSource(tag) {
return `(function ${tag}() { return \'${tag}\'; })`;
}
-function produce(source) {
- const script = new vm.Script(source, {
- produceCachedData: true
- });
- assert(!script.cachedDataProduced || script.cachedData instanceof Buffer);
+function produce(source, count) {
+ if (!count)
+ count = 1;
+
+ const out = spawnSync(process.execPath, [ '-e', `
+ var assert = require('assert');
+ var vm = require('vm');
+
+ let data;
+ for (var i = 0; i < ${count}; i++) {
+ var script = new vm.Script(process.argv[1], {
+ produceCachedData: true
+ });
+
+ assert(!script.cachedDataProduced || script.cachedData instanceof Buffer);
+
+ if (script.cachedDataProduced)
+ data = script.cachedData.toString('base64');
+ }
+ console.log(data);
+ `, source]);
+
+ assert.equal(out.status, 0, out.stderr + '');
- return script.cachedData;
+ return Buffer.from(out.stdout.toString(), 'base64');
}
function testProduceConsume() {
@@ -34,9 +53,7 @@ testProduceConsume();
function testProduceMultiple() {
const source = getSource('original');
- produce(source);
- produce(source);
- produce(source);
+ produce(source, 3);
}
testProduceMultiple();