Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 760AB1190C for ; Tue, 14 May 2013 04:22:45 +0000 (UTC) Received: (qmail 61247 invoked by uid 500); 14 May 2013 04:15:14 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 60792 invoked by uid 500); 14 May 2013 04:15:13 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 60334 invoked by uid 99); 14 May 2013 04:15:09 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 May 2013 04:15:09 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 32EAC7DC8; Tue, 14 May 2013 04:15:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lorinbeer@apache.org To: commits@cordova.apache.org Date: Tue, 14 May 2013 04:15:18 -0000 Message-Id: <5dd70c0e940a450b87cd20b318fbcaa0@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [11/50] [abbrv] webworks commit: create integration tests create integration tests Reviewed by Bryan Higgins Tested by Tracy Li Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/34ff4f18 Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/34ff4f18 Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/34ff4f18 Branch: refs/heads/master Commit: 34ff4f18c86a8c3700199f65dd5a63c6d81d38a6 Parents: b4ee225 Author: Hasan Ahmad Authored: Fri Mar 22 11:30:55 2013 -0400 Committer: Bryan Higgins Committed: Fri May 3 10:13:29 2013 -0400 ---------------------------------------------------------------------- blackberry10/bin/create.js | 4 +- .../bin/test/cordova/integration/create.js | 158 +++++++++++++++ .../bin/test/cordova/integration/target.js | 3 - 3 files changed, 160 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/blackberry10/bin/create.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js index 7a0950b..9b99435 100644 --- a/blackberry10/bin/create.js +++ b/blackberry10/bin/create.js @@ -141,7 +141,6 @@ var build, process.exit(1); } else { - console.log("Project creation complete!"); process.exit(); } } @@ -156,7 +155,8 @@ var build, .andThen(clean) .andThen(copyJavascript) .andThen(copyFilesToProject) - .andThen(updateProject); + .andThen(updateProject) + .andThen(clean); build.start(function (error) { done(error); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/blackberry10/bin/test/cordova/integration/create.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/test/cordova/integration/create.js b/blackberry10/bin/test/cordova/integration/create.js new file mode 100644 index 0000000..d193580 --- /dev/null +++ b/blackberry10/bin/test/cordova/integration/create.js @@ -0,0 +1,158 @@ +/** + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +var childProcess = require('child_process'), + tempFolder = '.tmp/', + appFolder = tempFolder + 'tempCordovaApp/', + projectFile = 'project.json', + wrench = require('wrench'), + fs = require('fs'), + flag = false, + _stdout = "", + _stderr = ""; + +function executeScript(shellCommand) { + childProcess.exec(shellCommand, function (error, stdout, stderr) { + if (error) { + console.log("Error executing command: " + error); + } + _stdout = stdout.toString().trim(); + _stderr = stderr.toString().trim(); + flag = true; + }); +} + +describe("create tests", function () { + it("creates project", function () { + var project, + appIdRegExp = /id="default\.app\.id"/g; + executeScript("bin/create " + appFolder); + waitsFor(function () { + return flag; + }); + runs(function () { + flag = false; + project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8")); + expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true); + expect(fs.existsSync(appFolder)).toEqual(true); + expect(fs.existsSync(appFolder + "/plugins")).toEqual(true); + expect(fs.existsSync(appFolder + "/cordova")).toEqual(true); + expect(fs.existsSync(appFolder + "/cordova/node_modules")).toEqual(true); + expect(fs.existsSync(appFolder + "/cordova/lib")).toEqual(true); + expect(fs.existsSync(appFolder + "/cordova/third_party")).toEqual(true); + expect(fs.existsSync(appFolder + "/www")).toEqual(true); + expect(project.barName).toEqual("cordova-BB10-app"); + expect(project.keystorepass).toEqual("password"); + expect(project.defaultTarget).toEqual(""); + expect(project.targets).toEqual({}); + expect(fs.existsSync("./build")).toEqual(false); + expect(_stdout).toEqual(""); + expect(_stderr).toEqual(""); + }); + this.after(function () { + wrench.rmdirSyncRecursive(tempFolder); + }); + }); + + it("sets appId", function () { + var configEt, + appIdRegExp = /id="com\.example\.bb10app"/g; + executeScript("bin/create " + appFolder + " com.example.bb10app"); + waitsFor(function () { + return flag; + }); + runs(function () { + flag = false; + expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true); + expect(_stdout).toEqual(""); + expect(_stderr).toEqual(""); + }); + this.after(function () { + wrench.rmdirSyncRecursive(tempFolder); + }); + }); + + it("sets appId and barName", function () { + var project, + appIdRegExp = /id="com\.example\.bb10app"/g; + executeScript("bin/create " + appFolder + " com.example.bb10app bb10appV1"); + waitsFor(function () { + return flag; + }); + runs(function () { + flag = false; + project = JSON.parse(fs.readFileSync(appFolder + projectFile, "utf-8")); + expect(appIdRegExp.test(fs.readFileSync(appFolder + "www/config.xml", "utf-8"))).toEqual(true); + expect(project.barName).toEqual("bb10appV1"); + expect(_stdout).toEqual(""); + expect(_stderr).toEqual(""); + }); + this.after(function () { + wrench.rmdirSyncRecursive(tempFolder); + }); + }); + + it("No args", function () { + executeScript("bin/create"); + waitsFor(function () { + return flag; + }); + runs(function () { + flag = false; + expect(_stdout).toEqual("You must give a project PATH"); + expect(_stderr).toEqual(""); + }); + }); + + it("Empty dir error", function () { + executeScript("bin/create ./"); + waitsFor(function () { + return flag; + }); + runs(function () { + flag = false; + expect(_stdout).toEqual("The project path must be an empty directory"); + expect(_stderr).toEqual(""); + }); + }); + + it("Invalid appId error", function () { + executeScript("bin/create " + appFolder + " 23.21#$"); + waitsFor(function () { + return flag; + }); + runs(function () { + flag = false; + expect(_stdout).toEqual("App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters"); + expect(_stderr).toEqual(""); + }); + }); + + it("Invalid barName error", function () { + executeScript("bin/create " + appFolder + " com.example.app %bad@bar^name"); + waitsFor(function () { + return flag; + }); + runs(function () { + flag = false; + expect(_stdout).toEqual("BAR filename can only contain alpha-numeric, '.', '-' and '_' characters"); + expect(_stderr).toEqual(""); + }); + }); +}); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/34ff4f18/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 62eab37..e948a87 100644 --- a/blackberry10/bin/test/cordova/integration/target.js +++ b/blackberry10/bin/test/cordova/integration/target.js @@ -46,9 +46,6 @@ describe("cordova/target tests", function () { }); runs(function () { flag = false; - expect(fs.existsSync(appFolder)).toEqual(true); - expect(_stdout).toEqual("Project creation complete!"); - expect(_stderr).toEqual(""); }); });