Skip to content

Commit

Permalink
Merge pull request adobe#3198 from adobe/dangoor/testing-domain
Browse files Browse the repository at this point in the history
Enable installation tests
  • Loading branch information
njx committed Mar 21, 2013
2 parents 7d357f2 + 876f618 commit 5a0fbcd
Show file tree
Hide file tree
Showing 87 changed files with 3,451 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Expand Up @@ -48,7 +48,8 @@ module.exports = function (grunt) {
'!test/spec/*-files/**/*.js',
'!test/smokes/**',
'!test/temp/**',
'!test/thirdparty/**'
'!test/thirdparty/**',
'!test/**/node_modules/**/*.js'
],
grunt: [
'Gruntfile.js',
Expand Down
57 changes: 57 additions & 0 deletions test/SpecRunner.js
Expand Up @@ -50,6 +50,7 @@ define(function (require, exports, module) {
NativeFileSystem = require("file/NativeFileSystem").NativeFileSystem,
UrlParams = require("utils/UrlParams").UrlParams,
UnitTestReporter = require("test/UnitTestReporter").UnitTestReporter,
NodeConnection = require("utils/NodeConnection"),
BootstrapReporterView = require("test/BootstrapReporterView").BootstrapReporterView;

// Load modules that self-register and just need to get included in the main project
Expand All @@ -67,8 +68,17 @@ define(function (require, exports, module) {
var suite,
params = new UrlParams(),
reporter,
_nodeConnectionDeferred = new $.Deferred(),
reporterView;

/**
* @const
* Amount of time to wait before automatically rejecting the connection
* deferred. If we hit this timeout, we'll never have a node connection
* for the installer in this run of Brackets.
*/
var NODE_CONNECTION_TIMEOUT = 30000; // 30 seconds - TODO: share with StaticServer?

params.parse();

function _loadExtensionTests(suite) {
Expand Down Expand Up @@ -157,6 +167,39 @@ define(function (require, exports, module) {
}

function init() {
// Start up the node connection, which is held in the
// _nodeConnectionDeferred module variable. (Use
// _nodeConnectionDeferred.done() to access it.

// This is in SpecRunner rather than SpecRunnerUtils because the hope
// is to hook up jasmine-node tests in this test runner.

// TODO: duplicates code from StaticServer
// TODO: can this be done lazily?

var connectionTimeout = setTimeout(function () {
console.error("[SpecRunner] Timed out while trying to connect to node");
_nodeConnectionDeferred.reject();
}, NODE_CONNECTION_TIMEOUT);

var _nodeConnection = new NodeConnection();
_nodeConnection.connect(true).then(function () {
var domainPath = FileUtils.getNativeBracketsDirectoryPath() + "/" + FileUtils.getNativeModuleDirectoryPath(module) + "/../test/node/TestingDomain";

_nodeConnection.loadDomains(domainPath, true)
.then(
function () {
clearTimeout(connectionTimeout);
_nodeConnectionDeferred.resolve(_nodeConnection);
},
function () { // Failed to connect
console.error("[SpecRunner] Failed to connect to node", arguments);
clearTimeout(connectionTimeout);
_nodeConnectionDeferred.reject();
}
);
});

suite = params.get("suite") || localStorage.getItem("SpecRunner.suite") || "UnitTestSuite";

// Create a top-level filter to show/hide performance and extensions tests
Expand Down Expand Up @@ -260,5 +303,19 @@ define(function (require, exports, module) {
});
}

/**
* Allows access to the deferred that manages the node connection for tests.
*
* @return {jQuery.Deferred} The deferred that manages the node connection
*/
function getNodeConnectionDeferred() {
return _nodeConnectionDeferred;
}

// this is used by SpecRunnerUtils
brackets.testing = {
getNodeConnectionDeferred: getNodeConnectionDeferred
};

init();
});
54 changes: 54 additions & 0 deletions test/node/TestingDomain.js
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/


/*jslint vars: true, plusplus: true, devel: true, node: true, nomen: true,
indent: 4, maxerr: 50 */

"use strict";

var fs = require("fs-extra");

/**
* Initialize the "testing" domain.
* The testing domain provides utilities for tests.
*/
function init(domainManager) {
if (!domainManager.hasDomain("testing")) {
domainManager.registerDomain("testing", {major: 0, minor: 1});
}
domainManager.registerCommand(
"testing",
"remove",
fs.remove,
true,
"Remove the directory at the path",
[{
name: "path",
type: "string",
description: "path to the directory to remove"
}]
);
}

exports.init = init;
1 change: 1 addition & 0 deletions test/node/node_modules/fs-extra/.npmignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions test/node/node_modules/fs-extra/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions test/node/node_modules/fs-extra/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions test/node/node_modules/fs-extra/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a0fbcd

Please sign in to comment.