Skip to content

Commit

Permalink
minor code style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 26, 2015
1 parent 84fb575 commit fa70351
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
26 changes: 21 additions & 5 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function Runner(opts) {
EventEmitter.call(this);

this.results = [];

this.tests = [];

this.test = makeChain({
Expand Down Expand Up @@ -156,17 +155,34 @@ 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,
passCount: 0,
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);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit fa70351

Please sign in to comment.