Skip to content
Browse files

Add suite param option to SpecRunner and to grunt test-integration ta…

…sk. Fix bug in NativeFileSystem where an empty dir will list the entire disk contents.
  • Loading branch information...
1 parent 1166449 commit 0315b1629ddf7ac5c682e89ca20f709b740b6b27 @jasonsanjose jasonsanjose committed
View
50 src/extensions/default/JavaScriptCodeHints/ScopeManager.js
@@ -425,33 +425,37 @@ define(function (require, exports, module) {
var path = document.file.fullPath,
split = HintUtils.splitPath(path),
dir = split.dir,
- file = split.file,
- dirEntry = new NativeFileSystem.DirectoryEntry(dir),
- reader = dirEntry.createReader();
-
- markFileDirty(dir, file);
-
- reader.readEntries(function (entries) {
- entries.slice(0, MAX_FILES_IN_DIR).forEach(function (entry) {
- if (entry.isFile) {
- var path = entry.fullPath,
- split = HintUtils.splitPath(path),
- dir = split.dir,
- file = split.file;
-
- if (file.indexOf(".") > 1) { // ignore /.dotfiles
- var languageID = LanguageManager.getLanguageForPath(entry.fullPath).getId();
- if (languageID === HintUtils.LANGUAGE_ID) {
- DocumentManager.getDocumentForPath(path).done(function (document) {
- refreshOuterScope(dir, file, document.getText());
- });
+ file = split.file;
+
+ NativeFileSystem.resolveNativeFileSystemPath(dir, function (dirEntry) {
+ var reader = dirEntry.createReader();
+
+ markFileDirty(dir, file);
+
+ reader.readEntries(function (entries) {
+ entries.slice(0, MAX_FILES_IN_DIR).forEach(function (entry) {
+ if (entry.isFile) {
+ var path = entry.fullPath,
+ split = HintUtils.splitPath(path),
+ dir = split.dir,
+ file = split.file;
+
+ if (file.indexOf(".") > 1) { // ignore /.dotfiles
+ var languageID = LanguageManager.getLanguageForPath(entry.fullPath).getId();
+ if (languageID === HintUtils.LANGUAGE_ID) {
+ DocumentManager.getDocumentForPath(path).done(function (document) {
+ refreshOuterScope(dir, file, document.getText());
+ });
+ }
}
}
- }
+ });
+ }, function (err) {
+ console.log("Unable to refresh directory: " + err);
+ refreshOuterScope(dir, file, document.getText());
});
}, function (err) {
- console.log("Unable to refresh directory: " + err);
- refreshOuterScope(dir, file, document.getText());
+ console.log("Directory \"%s\" does not exist", dir);
});
}
View
5 src/file/NativeFileSystem.js
@@ -946,6 +946,11 @@ define(function (require, exports, module) {
* @param {function(DOMError)=} errorCallback Callback function for error operations
*/
NativeFileSystem.DirectoryReader.prototype.readEntries = function (successCallback, errorCallback) {
+ if (!this._directory.fullPath) {
+ errorCallback(new NativeFileError(NativeFileError.PATH_EXISTS_ERR));
+ return;
+ }
+
var rootPath = this._directory.fullPath,
filesystem = this.filesystem,
timeout = NativeFileSystem.ASYNC_TIMEOUT,
View
3 tasks/test.js
@@ -37,10 +37,11 @@ module.exports = function (grunt) {
opts = { cwd: process.cwd() },
cmd = common.resolve(grunt.option("shell") || grunt.config("shell." + platform)),
spec = grunt.option("spec") || "all",
+ suite = grunt.option("suite") || "all",
results = grunt.option("results") || process.cwd() + "/results.json",
resultsPath = common.resolve(results),
specRunnerPath = common.resolve("test/SpecRunner.html"),
- args = " --startup-path=\"" + specRunnerPath + "?suite=all&spec=" + encodeURIComponent(spec) + "&resultsPath=" + encodeURIComponent(resultsPath) + "\"";
+ args = " --startup-path=\"" + specRunnerPath + "?suite=" + encodeURIComponent(suite) + "&spec=" + encodeURIComponent(spec) + "&resultsPath=" + encodeURIComponent(resultsPath) + "\"";
if (platform === "win") {
cmd += args;
View
8 test/SpecRunner.html
@@ -64,10 +64,10 @@
<div class="nav-collapse">
<ul class="nav">
<li><a id="all" href="?suite=all">All</a></li>
- <li><a id="UnitTestSuite" href="?suite=UnitTestSuite">Unit</a></li>
- <li><a id="IntegrationTestSuite" href="?suite=IntegrationTestSuite">Integration</a></li>
- <li><a id="PerformanceTestSuite" href="?suite=PerformanceTestSuite">Performance</a></li>
- <li><a id="ExtensionTestSuite" href="?suite=ExtensionTestSuite">Extensions</a></li>
+ <li><a id="unit" href="?suite=unit">Unit</a></li>
+ <li><a id="integration" href="?suite=integration">Integration</a></li>
+ <li><a id="performance" href="?suite=performance">Performance</a></li>
+ <li><a id="extension" href="?suite=extension">Extensions</a></li>
<li><a id="reload" href="#">Reload</a></li>
<li><a id="show-dev-tools" href="#">Show Developer Tools</a></li>
</ul>
View
73 test/SpecRunner.js
@@ -65,7 +65,7 @@ define(function (require, exports, module) {
require("test/UnitTestSuite");
require("test/PerformanceTestSuite");
- var selectedSuite,
+ var selectedSuites,
params = new UrlParams(),
reporter,
_nodeConnectionDeferred = new $.Deferred(),
@@ -81,7 +81,7 @@ define(function (require, exports, module) {
params.parse();
- function _loadExtensionTests(suite) {
+ function _loadExtensionTests() {
// augment jasmine to identify extension unit tests
var addSuite = jasmine.Runner.prototype.addSuite;
jasmine.Runner.prototype.addSuite = function (suite) {
@@ -93,7 +93,7 @@ define(function (require, exports, module) {
paths = ["default"];
// load dev and user extensions only when running the extension test suite
- if (suite === "ExtensionTestSuite") {
+ if (selectedSuites.indexOf("extension")) {
paths.push("dev");
paths.push(ExtensionLoader.getUserExtensionPath());
}
@@ -127,7 +127,9 @@ define(function (require, exports, module) {
window.location.reload(true);
});
- $("#" + selectedSuite).closest("li").toggleClass("active", true);
+ if (selectedSuites.length === 1) {
+ $("#" + (selectedSuites[0])).closest("li").toggleClass("active", true);
+ }
AppInit._dispatchReady(AppInit.APP_READY);
@@ -200,22 +202,10 @@ define(function (require, exports, module) {
);
});
- selectedSuite = params.get("suite") || localStorage.getItem("SpecRunner.suite") || "UnitTestSuite";
+ selectedSuites = (params.get("suite") || localStorage.getItem("SpecRunner.suite") || "unit").split(",");
// Create a top-level filter to show/hide performance and extensions tests
- var runAll = (selectedSuite === "all"),
- isPerfSuite = (selectedSuite === "PerformanceTestSuite"),
- isExtSuite = (selectedSuite === "ExtensionTestSuite"),
- isIntegrationSuite = (selectedSuite === "IntegrationTestSuite"),
- category;
-
- if (isPerfSuite) {
- category = "performance";
- } else if (isIntegrationSuite) {
- category = "integration";
- } else if (isExtSuite) {
- category = "extension";
- }
+ var runAll = (selectedSuites.indexOf("all") >= 0);
var topLevelFilter = function (spec) {
// special case "all" suite to run unit, perf, extension, and integration tests
@@ -223,40 +213,25 @@ define(function (require, exports, module) {
return true;
}
- var currentSuite = spec.suite;
-
- // unit test suites have no category
- if (!isPerfSuite && !isExtSuite && !isIntegrationSuite) {
- if (spec.category !== undefined) {
- // if an individualy spec has a category, filter it out
- return false;
- }
-
+ var currentSuite = spec.suite,
+ category = spec.category;
+
+ if (!category) {
+ // find the category from the closest suite
while (currentSuite) {
- if (currentSuite.category !== undefined) {
- // any suite in the hierarchy may specify a category
- return false;
+ if (currentSuite.category) {
+ category = currentSuite.category;
+ break;
}
-
+
currentSuite = currentSuite.parentSuite;
}
-
- return true;
- }
-
- if (spec.category === category) {
- return true;
- }
-
- while (currentSuite) {
- if (currentSuite.category === category) {
- return true;
- }
-
- currentSuite = currentSuite.parentSuite;
}
- return false;
+ // if unit tests are selected, make sure there is no category in the heirarchy
+ // if not a unit test, make sure the category is selected
+ return (selectedSuites.indexOf("unit") >= 0 && category === undefined) ||
+ (selectedSuites.indexOf(category) >= 0);
};
/*
@@ -266,9 +241,9 @@ define(function (require, exports, module) {
*/
// configure spawned test windows to load extensions
- SpecRunnerUtils.setLoadExtensionsInTestWindow(isExtSuite);
+ SpecRunnerUtils.setLoadExtensionsInTestWindow(selectedSuites.indexOf("extension") >= 0);
- _loadExtensionTests(selectedSuite).done(function () {
+ _loadExtensionTests(selectedSuites).done(function () {
var jasmineEnv = jasmine.getEnv();
// Initiailize unit test preferences for each spec
@@ -302,7 +277,7 @@ define(function (require, exports, module) {
reporterView = new BootstrapReporterView(document, reporter);
// remember the suite for the next unit test window launch
- localStorage.setItem("SpecRunner.suite", selectedSuite);
+ localStorage.setItem("SpecRunner.suite", selectedSuites);
$(window.document).ready(_documentReadyHandler);
});
View
3 test/spec/SpecRunnerUtils.js
@@ -156,7 +156,8 @@ define(function (require, exports, module) {
// Prevent adding doc to working set
docToShim._handleEditorChange = function (event, editor, changeList) {
- this.isDirty = true;
+ var wasDirty = this.isDirty;
+ this.isDirty = !editor._codeMirror.isClean();
// TODO: This needs to be kept in sync with Document._handleEditorChange(). In the
// future, we should fix things so that we either don't need mock documents or that this

0 comments on commit 0315b16

Please sign in to comment.
Something went wrong with that request. Please try again.