Skip to content
This repository was archived by the owner on Jun 5, 2020. It is now read-only.

Commit a1b74d0

Browse files
committed
only try to run tests for configuration groups with tests specified
1 parent f2b264d commit a1b74d0

File tree

4 files changed

+67
-33
lines changed

4 files changed

+67
-33
lines changed

lib/run-analyzer.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,19 @@ exports.create = function (logger, options) {
3131
analyzer.run = function (runner, config, cb) {
3232
var callback = once(cb);
3333
config.runExtensionHook("analyze", analyzer);
34-
var run = runner.run(config, options, callback);
35-
run.cacheable = options.cacheResources;
36-
37-
analyzer.on("fail", function (stats) {
38-
var err = analyzerError(stats);
39-
run.abort(err);
40-
callback(err);
41-
});
34+
35+
if (config.tests && config.tests.length > 0) {
36+
var run = runner.run(config, options, callback);
37+
run.cacheable = options.cacheResources;
38+
39+
analyzer.on("fail", function (stats) {
40+
var err = analyzerError(stats);
41+
run.abort(err);
42+
callback(err);
43+
});
44+
} else {
45+
callback();
46+
}
4247
};
4348

4449
return analyzer;

lib/runners/browser.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,7 @@ var testRun = {
226226
startSession: function (client, callback) {
227227
return function (resourceSet) {
228228
if (this.aborted) { return callback(); }
229-
// less than 3 files means, no test files were found
230-
if (resourceSet.loadPath.paths().length === 3) {
231-
return this.done();
232-
}
229+
233230
this.logger.info("Creating browser session");
234231

235232
resourceSet.addResource({

test/run-analyzer-test.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var buster = require("buster-node");
22
var assert = buster.assert;
3+
var refute = buster.refute;
34
var runAnalyzer = require("../lib/run-analyzer");
45
var cliHelper = require("buster-cli/test/test-helper");
56
var streamLogger = require("stream-logger");
@@ -31,7 +32,7 @@ buster.testCase("Analyzer helper", {
3132
this.analyzer = runAnalyzer.create(this.logger, {});
3233
this.run = { abort: this.spy() };
3334
this.runner = { run: this.stub().returns(this.run) };
34-
this.config = { runExtensionHook: this.spy() };
35+
this.config = { runExtensionHook: this.spy(), tests: ["test.js"] };
3536
},
3637

3738
"triggers analyze extension hook": function () {
@@ -49,6 +50,20 @@ buster.testCase("Analyzer helper", {
4950
assert.calledWith(this.runner.run, this.config, {});
5051
},
5152

53+
"not starts run if config.tests isn't defined": function () {
54+
this.config.tests = undefined;
55+
this.analyzer.run(this.runner, this.config);
56+
57+
refute.called(this.runner.run);
58+
},
59+
60+
"not starts run if config.tests is empty array": function () {
61+
this.config.tests = [];
62+
this.analyzer.run(this.runner, this.config);
63+
64+
refute.called(this.runner.run);
65+
},
66+
5267
"aborts run if analyzer fails": function () {
5368
this.analyzer.run(this.runner, this.config);
5469
this.analyzer.emit("fail", { errors: 42 });

test/test-cli-test.js

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ buster.testCase("Test CLI", {
119119
"node runs": {
120120
setUp: function () {
121121
cliHelper.writeFile("buster.js", "var config = module.exports;" +
122-
"config.server = { environment: 'node' }");
122+
"config.server = { environment: 'node', " +
123+
"tests: ['test.js'] }");
123124
},
124125

125126
"loads node runner": function (done) {
@@ -165,7 +166,8 @@ buster.testCase("Test CLI", {
165166
this.config = cliHelper.writeFile(
166167
"buster2.js",
167168
"var config = module.exports;" +
168-
"config.server = { environment: 'browser' }"
169+
"config.server = { environment: 'browser', " +
170+
"tests: ['test.js'] }"
169171
);
170172
this.cli = testCli.create(this.stdout, this.stderr, {
171173
runners: this.runners,
@@ -259,7 +261,8 @@ buster.testCase("Test CLI", {
259261
this.config = cliHelper.writeFile(
260262
"buster2.js",
261263
"var config = module.exports;" +
262-
"config.server = { environment: 'browser' }"
264+
"config.server = { environment: 'browser', " +
265+
"tests: ['test.js'] }"
263266
);
264267
},
265268

@@ -438,8 +441,10 @@ buster.testCase("Test CLI", {
438441
this.config = cliHelper.writeFile(
439442
"buster2.js",
440443
"var config = module.exports;" +
441-
"config['browser tests'] = { environment: 'browser' };" +
442-
"config['node tests'] = { environment: 'node' };"
444+
"config['browser tests'] = { environment: 'browser', " +
445+
"tests: ['test.js'] };" +
446+
"config['node tests'] = { environment: 'node', " +
447+
"tests: ['test.js'] };"
443448
);
444449
},
445450

@@ -475,8 +480,14 @@ buster.testCase("Test CLI", {
475480
var callback = this.spy();
476481
this.runners.fake = { run: this.stub().returns({}) };
477482
this.cli.runConfigGroups([
478-
{ environment: "fake", id: 1, runExtensionHook: this.spy() },
479-
{ environment: "fake", id: 2, runExtensionHook: this.spy() }
483+
{ environment: "fake",
484+
id: 1,
485+
runExtensionHook: this.spy(),
486+
tests: ['test.js'] },
487+
{ environment: "fake",
488+
id: 2,
489+
runExtensionHook: this.spy(),
490+
tests: ['test.js'] }
480491
], {}, callback);
481492

482493
assert.calledOnce(this.runners.fake.run);
@@ -487,8 +498,14 @@ buster.testCase("Test CLI", {
487498
var callback = this.spy();
488499
this.runners.fake = { run: this.stub().yields().returns({}) };
489500
this.cli.runConfigGroups([
490-
{ environment: "fake", id: 1, runExtensionHook: this.spy() },
491-
{ environment: "fake", id: 2, runExtensionHook: this.spy() }
501+
{ environment: "fake",
502+
id: 1,
503+
runExtensionHook: this.spy(),
504+
tests: ['test.js'] },
505+
{ environment: "fake",
506+
id: 2,
507+
runExtensionHook: this.spy(),
508+
tests: ['test.js'] }
492509
], {}, callback);
493510

494511
assert.calledTwice(this.runners.fake.run);
@@ -501,7 +518,8 @@ buster.testCase("Test CLI", {
501518
this.config = cliHelper.writeFile(
502519
"buster2.js",
503520
"var config = module.exports;" +
504-
"config.server = { environment: 'node' }"
521+
"config.server = { environment: 'node', " +
522+
"tests: ['test.js'] }"
505523
);
506524
},
507525

@@ -528,7 +546,8 @@ buster.testCase("Test CLI", {
528546
};
529547
this.fakeConfig = {
530548
environment: "fake",
531-
runExtensionHook: this.spy()
549+
runExtensionHook: this.spy(),
550+
tests: ["test.js"]
532551
};
533552
},
534553

@@ -541,10 +560,8 @@ buster.testCase("Test CLI", {
541560
"with code 0 when two test configurations pass": function () {
542561
this.results = [[null, { ok: true, tests: 1 }],
543562
[null, { ok: true, tests: 1 }]];
544-
this.cli.runConfigGroups([this.fakeConfig, {
545-
environment: "fake",
546-
runExtensionHook: this.spy()
547-
}], {}, this.done);
563+
this.cli.runConfigGroups([this.fakeConfig,
564+
this.fakeConfig], {}, this.done);
548565
assert.calledOnceWith(this.exit, 0);
549566
},
550567

@@ -563,10 +580,8 @@ buster.testCase("Test CLI", {
563580
"with code 1 when one of several test configus fails": function () {
564581
this.results = [[null, { ok: true, tests: 1 }],
565582
[null, { ok: false, tests: 1 }]];
566-
this.cli.runConfigGroups([this.fakeConfig, {
567-
environment: "fake",
568-
runExtensionHook: this.spy()
569-
}], {}, this.done);
583+
this.cli.runConfigGroups([this.fakeConfig,
584+
this.fakeConfig], {}, this.done);
570585
assert.calledOnceWith(this.exit, 1);
571586
},
572587

@@ -611,7 +626,9 @@ buster.testCase("Test CLI", {
611626
node: { run: this.stub().returns({}) },
612627
browser: { run: this.stub().returns({}) }
613628
};
614-
this.config = { environment: "node", runExtensionHook: this.spy() };
629+
this.config = { environment: "node",
630+
runExtensionHook: this.spy(),
631+
tests: ['test.js'] };
615632
},
616633

617634
"are preloaded for environment": function () {

0 commit comments

Comments
 (0)