| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 318e075 commit e01cce5
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,25 +1,38 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - | ||
| 3 | - // Flags: --harmony-struct | ||
| 4 | - | ||
| 5 | 2 | const common = require('../common'); | |
| 6 | 3 | const assert = require('assert'); | |
| 4 | + const { spawnSync } = require('child_process'); | ||
| 7 | 5 | const { Worker, parentPort } = require('worker_threads'); | |
| 8 | 6 | ||
| 9 | - // Do not use isMainThread so that this test itself can be run inside a Worker. | ||
| 10 | - if (!process.env.HAS_STARTED_WORKER) { | ||
| 11 | - process.env.HAS_STARTED_WORKER = 1; | ||
| 12 | - const m = new globalThis.SharedArray(16); | ||
| 7 | + if (process.env.TEST_CHILD_PROCESS === '1') { | ||
| 8 | + // Do not use isMainThread so that this test itself can be run inside a Worker. | ||
| 9 | + if (!process.env.HAS_STARTED_WORKER) { | ||
| 10 | + process.env.HAS_STARTED_WORKER = 1; | ||
| 11 | + const m = new globalThis.SharedArray(16); | ||
| 13 | 12 | ||
| 14 | - const worker = new Worker(__filename); | ||
| 15 | - worker.once('message', common.mustCall((message) => { | ||
| 16 | - assert.strictEqual(message, m); | ||
| 17 | - })); | ||
| 13 | + const worker = new Worker(__filename); | ||
| 14 | + worker.once('message', common.mustCall((message) => { | ||
| 15 | + assert.strictEqual(message, m); | ||
| 16 | + })); | ||
| 18 | 17 | ||
| 19 | - worker.postMessage(m); | ||
| 18 | + worker.postMessage(m); | ||
| 19 | + } else { | ||
| 20 | + parentPort.once('message', common.mustCall((message) => { | ||
| 21 | + // Simple echo. | ||
| 22 | + parentPort.postMessage(message); | ||
| 23 | + })); | ||
| 24 | + } | ||
| 20 | 25 | } else { | |
| 21 | - parentPort.once('message', common.mustCall((message) => { | ||
| 22 | - // Simple echo. | ||
| 23 | - parentPort.postMessage(message); | ||
| 24 | - })); | ||
| 26 | + if (process.config.variables.v8_enable_pointer_compression === 1) { | ||
| 27 | + common.skip('--harmony-struct cannot be used with pointer compression'); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + const args = ['--harmony-struct', __filename]; | ||
| 31 | + const options = { env: { TEST_CHILD_PROCESS: '1', ...process.env } }; | ||
| 32 | + const child = spawnSync(process.execPath, args, options); | ||
| 33 | + | ||
| 34 | + assert.strictEqual(child.stderr.toString().trim(), ''); | ||
| 35 | + assert.strictEqual(child.stdout.toString().trim(), ''); | ||
| 36 | + assert.strictEqual(child.status, 0); | ||
| 37 | + assert.strictEqual(child.signal, null); | ||
| 25 | 38 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments