Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 8935d2b

Browse files
committed
Merge pull request #3277 from adobe/jasonsanjose/all-suite
Add "all" suite to run unit, extension, performance and integration tests
2 parents 18474d1 + 2eeed34 commit 8935d2b

3 files changed

Lines changed: 35 additions & 31 deletions

File tree

tasks/test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ module.exports = function (grunt) {
3939
spec = grunt.option("spec") || "all",
4040
results = grunt.option("results") || process.cwd() + "/results.json",
4141
resultsPath = common.resolve(results),
42-
specRunnerPath = common.resolve("test/SpecRunner.html");
42+
specRunnerPath = common.resolve("test/SpecRunner.html"),
43+
args = " --startup-path=\"" + specRunnerPath + "?suite=all&spec=" + encodeURIComponent(spec) + "&resultsPath=" + encodeURIComponent(resultsPath) + "\"";
4344

4445
if (platform === "win") {
45-
cmd += " --startup-path=" + specRunnerPath + "?spec=" + spec + "^&resultsPath=" + encodeURIComponent(resultsPath);
46+
cmd += args;
4647
} else if (platform === "mac") {
47-
cmd = "open \"" + cmd + "\" -W --args --startup-path=\"" + specRunnerPath + "?spec=" + spec + "&resultsPath=" + encodeURIComponent(resultsPath) + "\"";
48+
cmd = "open \"" + cmd + "\" -W --args " + args;
4849
}
4950

5051
grunt.log.writeln(cmd);
@@ -56,8 +57,5 @@ module.exports = function (grunt) {
5657
done(false);
5758
});
5859
});
59-
60-
function execTest(task, platform) {
61-
}
6260

6361
};

test/SpecRunner.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<a class="brand" href="#">Brackets Tests</a>
6464
<div class="nav-collapse">
6565
<ul class="nav">
66+
<li><a id="all" href="?suite=all">All</a></li>
6667
<li><a id="UnitTestSuite" href="?suite=UnitTestSuite">Unit</a></li>
6768
<li><a id="IntegrationTestSuite" href="?suite=IntegrationTestSuite">Integration</a></li>
6869
<li><a id="PerformanceTestSuite" href="?suite=PerformanceTestSuite">Performance</a></li>

test/SpecRunner.js

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ define(function (require, exports, module) {
6565
require("test/UnitTestSuite");
6666
require("test/PerformanceTestSuite");
6767

68-
var suite,
68+
var selectedSuite,
6969
params = new UrlParams(),
7070
reporter,
7171
_nodeConnectionDeferred = new $.Deferred(),
@@ -127,7 +127,7 @@ define(function (require, exports, module) {
127127
window.location.reload(true);
128128
});
129129

130-
$("#" + suite).closest("li").toggleClass("active", true);
130+
$("#" + selectedSuite).closest("li").toggleClass("active", true);
131131

132132
AppInit._dispatchReady(AppInit.APP_READY);
133133

@@ -200,15 +200,30 @@ define(function (require, exports, module) {
200200
);
201201
});
202202

203-
suite = params.get("suite") || localStorage.getItem("SpecRunner.suite") || "UnitTestSuite";
203+
selectedSuite = params.get("suite") || localStorage.getItem("SpecRunner.suite") || "UnitTestSuite";
204204

205205
// Create a top-level filter to show/hide performance and extensions tests
206-
var isPerfSuite = (suite === "PerformanceTestSuite"),
207-
isExtSuite = (suite === "ExtensionTestSuite"),
208-
isIntegrationSuite = (suite === "IntegrationTestSuite");
206+
var runAll = (selectedSuite === "all"),
207+
isPerfSuite = (selectedSuite === "PerformanceTestSuite"),
208+
isExtSuite = (selectedSuite === "ExtensionTestSuite"),
209+
isIntegrationSuite = (selectedSuite === "IntegrationTestSuite"),
210+
category;
211+
212+
if (isPerfSuite) {
213+
category = "performance";
214+
} else if (isIntegrationSuite) {
215+
category = "integration";
216+
} else if (isExtSuite) {
217+
category = "extension";
218+
}
209219

210220
var topLevelFilter = function (spec) {
211-
var suite = spec.suite;
221+
// special case "all" suite to run unit, perf, extension, and integration tests
222+
if (runAll) {
223+
return true;
224+
}
225+
226+
var currentSuite = spec.suite;
212227

213228
// unit test suites have no category
214229
if (!isPerfSuite && !isExtSuite && !isIntegrationSuite) {
@@ -217,38 +232,28 @@ define(function (require, exports, module) {
217232
return false;
218233
}
219234

220-
while (suite) {
221-
if (suite.category !== undefined) {
235+
while (currentSuite) {
236+
if (currentSuite.category !== undefined) {
222237
// any suite in the hierarchy may specify a category
223238
return false;
224239
}
225240

226-
suite = suite.parentSuite;
241+
currentSuite = currentSuite.parentSuite;
227242
}
228243

229244
return true;
230245
}
231246

232-
var category;
233-
234-
if (isPerfSuite) {
235-
category = "performance";
236-
} else if (isIntegrationSuite) {
237-
category = "integration";
238-
} else {
239-
category = "extension";
240-
}
241-
242247
if (spec.category === category) {
243248
return true;
244249
}
245250

246-
while (suite) {
247-
if (suite.category === category) {
251+
while (currentSuite) {
252+
if (currentSuite.category === category) {
248253
return true;
249254
}
250255

251-
suite = suite.parentSuite;
256+
currentSuite = currentSuite.parentSuite;
252257
}
253258

254259
return false;
@@ -263,7 +268,7 @@ define(function (require, exports, module) {
263268
// configure spawned test windows to load extensions
264269
SpecRunnerUtils.setLoadExtensionsInTestWindow(isExtSuite);
265270

266-
_loadExtensionTests(suite).done(function () {
271+
_loadExtensionTests(selectedSuite).done(function () {
267272
var jasmineEnv = jasmine.getEnv();
268273

269274
// Initiailize unit test preferences for each spec
@@ -297,7 +302,7 @@ define(function (require, exports, module) {
297302
reporterView = new BootstrapReporterView(document, reporter);
298303

299304
// remember the suite for the next unit test window launch
300-
localStorage.setItem("SpecRunner.suite", suite);
305+
localStorage.setItem("SpecRunner.suite", selectedSuite);
301306

302307
$(window.document).ready(_documentReadyHandler);
303308
});

0 commit comments

Comments
 (0)