diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 05760f6..b913cce 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -5,9 +5,11 @@ name: Node.js CI on: push: - branches: [ master ] + branches: + - master pull_request: - branches: [ master ] + branches: + - master schedule: - cron: '0 2 * * *' @@ -18,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [12, 14] + node-version: [12, 14, 16] os: [ubuntu-latest, windows-latest, macos-latest] steps: diff --git a/lib/cmd/start.js b/lib/cmd/start.js index 8445a63..add1e2a 100644 --- a/lib/cmd/start.js +++ b/lib/cmd/start.js @@ -131,6 +131,7 @@ class StartCommand extends Command { // additional execArgv execArgvObj.deprecation = false; // --no-deprecation + execArgvObj.traceWarnings = true; // --trace-warnings const command = argv.node || 'node'; diff --git a/test/fixtures/trace-warnings/app.js b/test/fixtures/trace-warnings/app.js new file mode 100644 index 0000000..9eee040 --- /dev/null +++ b/test/fixtures/trace-warnings/app.js @@ -0,0 +1,14 @@ +'use strict'; + +const Event = require('events'); +const event = new Event(); +event.setMaxListeners(1); + +module.exports = () => { + // --trace-warnings test about MaxListenersExceededWarning + event.on('xx', () => {}); + event.on('xx', () => {}); + + // will not effect --no-deprecation argv + new Buffer('aaa'); +}; diff --git a/test/fixtures/trace-warnings/package.json b/test/fixtures/trace-warnings/package.json new file mode 100644 index 0000000..dfc4b17 --- /dev/null +++ b/test/fixtures/trace-warnings/package.json @@ -0,0 +1,4 @@ +{ + "name": "trace-warnings", + "version": "1.0.0" +} diff --git a/test/start.test.js b/test/start.test.js index d7b217c..ca22a4b 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -123,6 +123,18 @@ describe('test/start.test.js', () => { assert(result.data.toString() === 'hi, egg'); }); + it('should start --trace-warnings work', function* () { + app = coffee.fork(eggBin, [ 'start', '--workers=1', path.join(__dirname, 'fixtures/trace-warnings') ]); + app.debug(); + app.expect('code', 0); + + yield sleep(waitTime); + + assert(app.stderr.includes('MaxListenersExceededWarning:')); + assert(app.stderr.includes('app.js:10:9')); // should had trace + assert(!app.stdout.includes('DeprecationWarning:')); + }); + it.skip('should get ready', function* () { app = coffee.fork(path.join(__dirname, './fixtures/ipc-bin/start.js'), [], { env: { diff --git a/test/stop.test.js b/test/stop.test.js index 95fe485..f15560c 100644 --- a/test/stop.test.js +++ b/test/stop.test.js @@ -64,7 +64,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.includes('[master] exit with code:0')); assert(app.stdout.includes('[app_worker] exit with code:0')); // assert(app.stdout.includes('[agent_worker] exit with code:0')); @@ -106,7 +106,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(stdout.includes('[master] receive signal SIGTERM, closing')); + assert(stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(stdout.includes('[master] exit with code:0')); assert(stdout.includes('[app_worker] exit with code:0')); } @@ -191,7 +191,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.includes('[master] exit with code:0')); assert(app.stdout.includes('[app_worker] exit with code:0')); // assert(app.stdout.includes('[agent_worker] exit with code:0')); @@ -248,7 +248,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.includes('[master] exit with code:0')); assert(app.stdout.includes('[app_worker] exit with code:0')); // assert(app.stdout.includes('[agent_worker] exit with code:0')); @@ -261,7 +261,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app2.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app2.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app2.stdout.includes('[master] exit with code:0')); assert(app2.stdout.includes('[app_worker] exit with code:0')); } @@ -275,7 +275,7 @@ describe('test/stop.test.js', () => { beforeEach(function* () { yield utils.cleanup(timeoutPath); app = coffee.fork(eggBin, [ 'start', '--workers=2', '--title=stop-timeout', timeoutPath ]); - // app.debug(); + app.debug(); app.expect('code', 0); yield sleep(waitTime); @@ -304,7 +304,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.match(/app_worker#\d+:\d+ disconnect/)); assert(app.stdout.match(/don't fork, because worker:\d+ will be kill soon/)); } @@ -326,7 +326,7 @@ describe('test/stop.test.js', () => { // no way to handle the SIGTERM signal in windows ? if (!isWin) { - assert(app.stdout.includes('[master] receive signal SIGTERM, closing')); + assert(app.stdout.includes('[master] master is killed by signal SIGTERM, closing')); assert(app.stdout.includes('[master] exit with code:0')); assert(app.stdout.includes('[agent_worker] exit with code:0')); }