1 | 'use strict'
|
2 |
|
3 | const test = require('tap').test
|
4 | const path = require('path')
|
5 | const async = require('async')
|
6 | const { spawn } = require('child_process')
|
7 | const endpoint = require('endpoint')
|
8 |
|
9 | test('cmd - collect - NODE_OPTIONS environment is not ignored', function (t) {
|
10 | const child = spawn(
|
11 | process.execPath, [
|
12 | path.resolve(__dirname, 'cmd-collect-node-options-env.script.js')
|
13 | ], {
|
14 | env: Object.assign({}, process.env, {
|
15 | NODE_OPTIONS: '--no-warnings --stack-trace-limit=4013'
|
16 | }),
|
17 | cwd: __dirname
|
18 | }
|
19 | )
|
20 |
|
21 | async.parallel({
|
22 | stdout (done) { child.stdout.pipe(endpoint(done)) },
|
23 | stderr (done) { child.stderr.pipe(endpoint(done)) }
|
24 | }, function (err, output) {
|
25 | if (err) return t.ifError(err)
|
26 |
|
27 |
|
28 | t.ok(output.stderr.toString().split('\n').length, 1)
|
29 | t.strictEqual(output.stdout.toString().trim(), '4013')
|
30 | t.end()
|
31 | })
|
32 | })
|