11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_cirequire('../common'); 41cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst execFile = require('child_process').execFile; 71cb0ef41Sopenharmony_ciconst warnmod = require.resolve(fixtures.path('warnings.js')); 81cb0ef41Sopenharmony_ciconst node = process.execPath; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst normal = [warnmod]; 111cb0ef41Sopenharmony_ciconst noWarn = ['--no-warnings', warnmod]; 121cb0ef41Sopenharmony_ciconst traceWarn = ['--trace-warnings', warnmod]; 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst warningMessage = /^\(.+\)\sWarning: a bad practice warning/; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciexecFile(node, normal, function(er, stdout, stderr) { 171cb0ef41Sopenharmony_ci // Show Process Warnings 181cb0ef41Sopenharmony_ci assert.strictEqual(er, null); 191cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 201cb0ef41Sopenharmony_ci assert.match(stderr, warningMessage); 211cb0ef41Sopenharmony_ci}); 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ciexecFile(node, noWarn, function(er, stdout, stderr) { 241cb0ef41Sopenharmony_ci // Hide Process Warnings 251cb0ef41Sopenharmony_ci assert.strictEqual(er, null); 261cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 271cb0ef41Sopenharmony_ci assert.doesNotMatch(stderr, warningMessage); 281cb0ef41Sopenharmony_ci}); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ciexecFile(node, traceWarn, function(er, stdout, stderr) { 311cb0ef41Sopenharmony_ci // Show Warning Trace 321cb0ef41Sopenharmony_ci assert.strictEqual(er, null); 331cb0ef41Sopenharmony_ci assert.strictEqual(stdout, ''); 341cb0ef41Sopenharmony_ci assert.match(stderr, warningMessage); 351cb0ef41Sopenharmony_ci assert.match(stderr, /at Object\.<anonymous>\s\(.+warnings\.js:3:9\)/); 361cb0ef41Sopenharmony_ci}); 37