From fa70351c3f132fbfd8a46a8366ff93cf1edde1d0 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 26 Nov 2015 16:29:25 +0700 Subject: [PATCH] minor code style tweaks --- cli.js | 2 +- lib/runner.js | 26 +++++++++++++++++++++----- lib/test.js | 3 ++- test/cli.js | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/cli.js b/cli.js index 8f88b1dcb..b13782214 100755 --- a/cli.js +++ b/cli.js @@ -182,7 +182,7 @@ function init(files) { return handlePaths(files) .map(function (file) { - return path.resolve('.', file); + return path.resolve(file); }) .then(function (files) { if (files.length === 0) { diff --git a/lib/runner.js b/lib/runner.js index 9273ea178..c7807f39a 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -26,7 +26,6 @@ function Runner(opts) { EventEmitter.call(this); this.results = []; - this.tests = []; this.test = makeChain({ @@ -156,9 +155,26 @@ Runner.prototype._addTestResult = function (test) { Runner.prototype.run = function () { var self = this; - var hasExclusive = Boolean(this.select({exclusive: true, skipped: false, type: 'test'}).length); - var serial = this.select({exclusive: hasExclusive, skipped: false, serial: true, type: 'test'}); - var concurrent = this.select({exclusive: hasExclusive, skipped: false, serial: false, type: 'test'}); + + var hasExclusive = this.select({ + exclusive: true, + skipped: false, + type: 'test' + }).length > 0; + + var serial = this.select({ + exclusive: hasExclusive, + skipped: false, + serial: true, + type: 'test' + }); + + var concurrent = this.select({ + exclusive: hasExclusive, + skipped: false, + serial: false, + type: 'test' + }); var stats = this.stats = { failCount: 0, @@ -166,7 +182,7 @@ Runner.prototype.run = function () { testCount: serial.length + concurrent.length }; - // Runner is executed directly in tests, in that case process.send() == undefined + // Runner is executed directly in tests, in that case `process.send() === undefined` if (process.send) { send('stats', stats); } diff --git a/lib/test.js b/lib/test.js index a2995b333..6667b7e45 100644 --- a/lib/test.js +++ b/lib/test.js @@ -115,7 +115,8 @@ Test.prototype.run = function () { // TODO(vdemedes): refactor this to avoid storing the promise if (!this.fn) { - return this.exit(); + this.exit(); + return undefined; } this._timeStart = globals.now(); diff --git a/test/cli.js b/test/cli.js index 628b292b3..086a77c1b 100644 --- a/test/cli.js +++ b/test/cli.js @@ -228,7 +228,7 @@ test('stack traces for exceptions are corrected using a source map, found via a test('absolute paths in CLI', function (t) { t.plan(2); - execCli([path.resolve('.', 'test/fixture/es2015.js')], function (err, stdout, stderr) { + execCli([path.resolve('test/fixture/es2015.js')], function (err, stdout, stderr) { t.ifError(err); t.is(stderr.trim(), '1 test passed'); t.end();