Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-env-var-no-warnings.js « parallel « test - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5b61e4163af6330f8b5fd71b6302df32ae1ff496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');

if (process.argv[2] === 'child') {
  process.emitWarning('foo');
} else {
  function test(env) {
    const cmd = `${process.execPath} ${__filename} child`;

    cp.exec(cmd, { env }, common.mustCall((err, stdout, stderr) => {
      assert.strictEqual(err, null);
      assert.strictEqual(stdout, '');

      if (env.NODE_NO_WARNINGS === '1')
        assert.strictEqual(stderr, '');
      else
        assert(/Warning: foo$/.test(stderr.trim()));
    }));
  }

  test({});
  test(process.env);
  test({ NODE_NO_WARNINGS: undefined });
  test({ NODE_NO_WARNINGS: null });
  test({ NODE_NO_WARNINGS: 'foo' });
  test({ NODE_NO_WARNINGS: true });
  test({ NODE_NO_WARNINGS: false });
  test({ NODE_NO_WARNINGS: {} });
  test({ NODE_NO_WARNINGS: [] });
  test({ NODE_NO_WARNINGS: function() {} });
  test({ NODE_NO_WARNINGS: 0 });
  test({ NODE_NO_WARNINGS: -1 });
  test({ NODE_NO_WARNINGS: '0' });
  test({ NODE_NO_WARNINGS: '01' });
  test({ NODE_NO_WARNINGS: '2' });
  // Don't test the number 1 because it will come through as a string in the
  // child process environment.
  test({ NODE_NO_WARNINGS: '1' });
}