You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2013/06/07 14:16:03 UTC

webworks commit: [CB-3518] Fix BB10 unit test runner for node > 0.9.9

Updated Branches:
  refs/heads/master ee54174f2 -> ad135dd97


[CB-3518] Fix BB10 unit test runner for node > 0.9.9

- update jasmine-node to 1.7.1
- make necessary changes to tests
- some test failures outstanding which need to be investigated

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>
Tested by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/ad135dd9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/ad135dd9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/ad135dd9

Branch: refs/heads/master
Commit: ad135dd978ca5a68a958b06946cfededbf04c992
Parents: ee54174
Author: Danyi Lin <da...@blackberry.com>
Authored: Fri May 24 15:49:53 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri Jun 7 08:17:31 2013 -0400

----------------------------------------------------------------------
 blackberry10/Jakefile                              |    4 +-
 .../bin/test/cordova/integration/target.js         |   16 +----
 blackberry10/bin/test/plugins/Contacts/index.js    |    2 +-
 blackberry10/framework/test/unit/lib/framework.js  |    5 ++
 .../test/unit/lib/policy/webkitOriginAccess.js     |    2 +-
 blackberry10/framework/test/unit/lib/webview.js    |   18 +++--
 blackberry10/package.json                          |    2 +-
 blackberry10/scripts/test.js                       |   57 +++++----------
 8 files changed, 40 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ad135dd9/blackberry10/Jakefile
----------------------------------------------------------------------
diff --git a/blackberry10/Jakefile b/blackberry10/Jakefile
index 81b2f6f..eb72dbd 100644
--- a/blackberry10/Jakefile
+++ b/blackberry10/Jakefile
@@ -62,13 +62,13 @@ function forEachFile(root, cbFile, cbDone) {
     scan(root);
 }
 
-desc("runs test");
+desc("runs hint and test");
 task('default', ['hint','test'], function () {});
 
 desc("run all tests in node - jake test [path]");
 task('test', [], function () {
     require('./scripts/test')(null, process.argv.length >= 4 ? process.argv[3] : null);
-});
+}, true);
 
 desc('check sources with JSHint');
 task('hint', ['complainwhitespace'], function () {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ad135dd9/blackberry10/bin/test/cordova/integration/target.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/integration/target.js b/blackberry10/bin/test/cordova/integration/target.js
index e948a87..0026295 100644
--- a/blackberry10/bin/test/cordova/integration/target.js
+++ b/blackberry10/bin/test/cordova/integration/target.js
@@ -30,7 +30,7 @@ var childProcess = require('child_process'),
 function executeScript(shellCommand) {
     childProcess.exec(shellCommand, function (error, stdout, stderr) {
         if (error) {
-            console.log("Error executing command: " + error);
+            //console.log("Error executing command: " + error);
         }
         _stdout = stdout.toString().trim();
         _stderr = stderr.toString().trim();
@@ -175,18 +175,6 @@ describe("cordova/target tests", function () {
         });
     });
 
-    it("should require type for add ", function () {
-        executeScript(appFolder + "cordova/target add z10 169.254.0.1");
-        waitsFor(function () {
-            return flag;
-        });
-        runs(function () {
-            flag = false;
-            expect(_stdout).toEqual("target type is required");
-            expect(_stderr).toEqual("");
-        });
-    });
-
     it("should warn unregonized command", function () {
         executeScript(appFolder + "cordova/target bleh");
         waitsFor(function () {
@@ -212,7 +200,7 @@ describe("cordova/target tests", function () {
     });
 
     it("should warn invalid type", function () {
-        executeScript(appFolder + "cordova/target add z10 169.254.0.1 bleh");
+        executeScript(appFolder + "cordova/target add z10 169.254.0.1 -t bleh");
         waitsFor(function () {
             return flag;
         });

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ad135dd9/blackberry10/bin/test/plugins/Contacts/index.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/plugins/Contacts/index.js b/blackberry10/bin/test/plugins/Contacts/index.js
index a14d89b..eb8c069 100644
--- a/blackberry10/bin/test/plugins/Contacts/index.js
+++ b/blackberry10/bin/test/plugins/Contacts/index.js
@@ -15,7 +15,7 @@
  */
 
 describe("Contacts", function () {
-    var _apiDir = __dirname + "./../../../templates/project/plugins/Contacts/src/blackberry10/",
+    var _apiDir = __dirname + "/../../../../plugins/Contacts/src/blackberry10/",
         index,
         ContactError = require(_apiDir + "ContactError"),
         ContactFindOptions = require(_apiDir + "ContactFindOptions"),

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ad135dd9/blackberry10/framework/test/unit/lib/framework.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/test/unit/lib/framework.js b/blackberry10/framework/test/unit/lib/framework.js
index 312dd8b..c37c2d6 100644
--- a/blackberry10/framework/test/unit/lib/framework.js
+++ b/blackberry10/framework/test/unit/lib/framework.js
@@ -56,6 +56,7 @@ describe("framework", function () {
         };
         mockedApplication = {
             addEventListener: jasmine.createSpy(),
+            removeEventListener: jasmine.createSpy(),
             webInspectorPort : "1337",
             invocation: {
                 invoke: jasmine.createSpy()
@@ -141,6 +142,10 @@ describe("framework", function () {
         delete GLOBAL.window;
         delete GLOBAL.qnx;
         delete GLOBAL.NamedNodeMap;
+        delete require.cache[require.resolve(srcPath + "webview")];
+        delete require.cache[require.resolve(srcPath + "overlayWebView")];
+        delete require.cache[require.resolve(srcPath + "controllerWebView")];
+        delete require.cache[require.resolve(srcPath + "framework")];
     });
 
     it("can start a webview instance", function () {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ad135dd9/blackberry10/framework/test/unit/lib/policy/webkitOriginAccess.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/test/unit/lib/policy/webkitOriginAccess.js b/blackberry10/framework/test/unit/lib/policy/webkitOriginAccess.js
index 4a5ac8e..292e95b 100644
--- a/blackberry10/framework/test/unit/lib/policy/webkitOriginAccess.js
+++ b/blackberry10/framework/test/unit/lib/policy/webkitOriginAccess.js
@@ -27,13 +27,13 @@ describe("lib/policy/webkitOriginAccess", function () {
         mockWebView = {
             addOriginAccessWhitelistEntry: jasmine.createSpy()
         };
+        webkitOriginAccess = require(LIB_PATH + "policy/webkitOriginAccess");
     });
 
     afterEach(function () {
         mockWebView = undefined;
         delete require.cache[require.resolve(LIB_PATH + "config")];
         delete require.cache[require.resolve(LIB_PATH + "policy/webkitOriginAccess")];
-        webkitOriginAccess = require(LIB_PATH + "policy/webkitOriginAccess");
     });
 
     function mockConfig(mockAccessList, hasMultiAccess) {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ad135dd9/blackberry10/framework/test/unit/lib/webview.js
----------------------------------------------------------------------
diff --git a/blackberry10/framework/test/unit/lib/webview.js b/blackberry10/framework/test/unit/lib/webview.js
index e96eb18..8a6b8e6 100644
--- a/blackberry10/framework/test/unit/lib/webview.js
+++ b/blackberry10/framework/test/unit/lib/webview.js
@@ -1,7 +1,9 @@
+var path = require('path');
+
 describe("webview", function () {
-    var libPath = "./../../../lib/",
-        networkResourceRequested = require(libPath + "webkitHandlers/networkResourceRequested"),
-        webkitOriginAccess = require(libPath + "policy/webkitOriginAccess"),
+    var libPath = path.join(__dirname, "../../../lib/"),
+        networkResourceRequested = require(path.join(libPath, "webkitHandlers/networkResourceRequested")),
+        webkitOriginAccess,
         webview,
         mockedController,
         mockedWebview,
@@ -9,7 +11,7 @@ describe("webview", function () {
         globalCreate;
 
     beforeEach(function () {
-        webview = require(libPath + "webview");
+        require.cache = {};
         mockedController = {
             enableWebInspector: undefined,
             enableCrossSiteXHR: undefined,
@@ -73,7 +75,7 @@ describe("webview", function () {
                     }
                     return mockedWebview;
                 },
-                getApplication: jasmine.createSpy()
+                getApplication: jasmine.createSpy().andReturn({windowVisible: false})
             }
         };
         GLOBAL.qnx = mockedQnx;
@@ -84,12 +86,12 @@ describe("webview", function () {
             width : 1024,
             height: 768
         };
+        webview = require(path.join(libPath, "webview"));
+        webkitOriginAccess = require(path.join(libPath, "policy/webkitOriginAccess"));
     });
 
     afterEach(function () {
-        delete GLOBAL.qnx;
-        delete GLOBAL.window;
-        delete GLOBAL.screen;
+        require.cache = {};
     });
 
     describe("create", function () {

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ad135dd9/blackberry10/package.json
----------------------------------------------------------------------
diff --git a/blackberry10/package.json b/blackberry10/package.json
index d1f25f7..84a7b19 100644
--- a/blackberry10/package.json
+++ b/blackberry10/package.json
@@ -31,7 +31,7 @@
   },
   "devDependencies": {
     "jake":"*",
-    "jasmine-node": "1.0.7"
+    "jasmine-node": "1.7.1"
   },
   "readmeFilename": "README.md"
 }

http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/ad135dd9/blackberry10/scripts/test.js
----------------------------------------------------------------------
diff --git a/blackberry10/scripts/test.js b/blackberry10/scripts/test.js
index 05408c1..1b2ce63 100644
--- a/blackberry10/scripts/test.js
+++ b/blackberry10/scripts/test.js
@@ -14,45 +14,24 @@
  * limitations under the License.
  */
 
-var wrench = require('wrench'),
-    path = require('path'),
-    fs = require('fs');
-
 module.exports = function (done, custom) {
     var jasmine = require('jasmine-node'),
-        verbose = false,
-        coloured = false,
-        specs = [
-            "framework/test",
-            "bin/test/cordova/integration",
-            "bin/test/cordova/unit",
-            "bin/test/plugins"
-        ];
-        key = {};
-
-    if (typeof custom !== "undefined" && fs.existsSync(custom)) {
-        specs = [custom];
-    }
-
-    for (key in jasmine) {
-        if (Object.prototype.hasOwnProperty.call(jasmine, key)) {
-            global[key] = jasmine[key];
-        }
-    }
-
-    function execSpecs(folders) {
-        var failed = 0;
-        if (folders.length > 0) {
-            console.log("Running tests in: " + folders[folders.length - 1]);
-            jasmine.executeSpecsInFolder(path.resolve(folders.pop()), function (runner) {
-                execSpecs(folders);
-                failed = runner.results().failedcount === 0 ? 0 : 1;
-            }, verbose, coloured);
-        }
-        else {
-            (typeof done !== "function" ? process.exit : done)(failed);
-        }
-    }
-
-    execSpecs(specs);
+        fs = require('fs'),
+        specs = (custom !== null && fs.existsSync(custom)) ? [custom]  :
+            [
+                "framework/test",
+                "bin/test/cordova/integration",
+                "bin/test/cordova/unit",
+                "bin/test/plugins"
+            ];
+    //console.log(specs);
+    jasmine.executeSpecsInFolder({
+        'specFolders': specs,
+        'onComplete': function (runner) {
+            var failedCount = runner.results().failedCount;
+            ((done && typeof done === "function") ?  done : process.exit)(failedCount);
+        }, 
+        'isVerbose': false,
+        'showColors': true
+    });
 };