cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] stevengill closed pull request #146: CB-12653 : added jasmine tests for coho util files
Date Thu, 01 Jan 1970 00:00:00 GMT
stevengill closed pull request #146: CB-12653 : added jasmine tests for coho util files
URL: https://github.com/apache/cordova-coho/pull/146
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.travis.yml b/.travis.yml
index 5eb3d60..1b02074 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,4 +8,4 @@ node_js:
 install: 
     - "npm install"
 script:
-    - "npm test"
+    - "npm test"
\ No newline at end of file
diff --git a/package.json b/package.json
index 2bd3377..5d5608f 100644
--- a/package.json
+++ b/package.json
@@ -60,4 +60,4 @@
     "Brian LeRoux"
   ],
   "license": "Apache-2.0"
-}
+}
\ No newline at end of file
diff --git a/spec/apputil.spec.js b/spec/apputil.spec.js
new file mode 100644
index 0000000..fa1351d
--- /dev/null
+++ b/spec/apputil.spec.js
@@ -0,0 +1,49 @@
+/*
+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 path = require('path');
+var chalk = require('chalk');
+var shell = require('shelljs');
+var apputil = require('../src/apputil');
+
+describe("apputil unit tests", function () {
+
+	it("Test#001 : print", function() {
+		spyOn(path, "relative").and.returnValue(true);
+		spyOn(console.log,"apply").and.returnValue(true);
+		apputil.print();
+		expect(path.relative.calls.count()).toEqual(0);
+		expect(console.log.apply.calls.count()).toEqual(1);
+	});
+
+	it("Test#002 : fatal", function() {
+		spyOn(console.error,"apply").and.returnValue(false);
+		spyOn(process,"exit").and.returnValue(false);
+		apputil.fatal();
+		expect(console.error.apply.calls.count()).toEqual(1);
+		expect(process.exit.calls.count()).toEqual(1);
+	});
+
+	it("Test#003 : initWorkingDir", function() {
+		spyOn(console,"log").and.returnValue(false);
+		apputil.initWorkingDir(true);
+		expect(console.log.calls.count()).toEqual(1);
+		expect(console.log.calls.allArgs()).toMatch("Running from");
+	});
+});
\ No newline at end of file
diff --git a/spec/executil.spec.js b/spec/executil.spec.js
new file mode 100644
index 0000000..6701761
--- /dev/null
+++ b/spec/executil.spec.js
@@ -0,0 +1,84 @@
+/*
+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 jasmine_co = require('jasmine-co').install();
+var executil = require('../src/executil');
+var superspawn = require('../src/superspawn');
+var apputil = require('../src/apputil');
+var Q = require("q");
+var deferred = Q.defer();
+var TIMEOUT = 60000;
+var androidRepo = { title: 'Android', 
+	id: 'android',
+	repoName: 'cordova-android',
+	jiraComponentName: 'Android',
+	cordovaJsPaths: [ 'bin/templates/project/assets/www/cordova.js' ],
+	remoteName: 'origin' };
+
+describe("executil unit tests", function () {
+	beforeEach(function () {
+		spyOn(apputil, "print").and.returnValue(true);
+		spyOn(superspawn, "spawn").and.returnValue(deferred.promise);
+	});
+
+	afterEach(function () {
+		apputil.print.calls.reset();
+	});
+
+	it("Test#001 : no commits are made", function () {
+		executil.reportGitPushResult(androidRepo, ['master', 'null']);
+		expect(apputil.print.calls.count()).toEqual(2);
+		expect(apputil.print.calls.argsFor(1)[0]).toEqual('All work complete. No commits were made.');
+	},TIMEOUT);
+
+	it("Test#002 : Don't print command, don't print output", function () {
+		executil.execHelper([ 'git', 'symbolic-ref', 'HEAD' ], true, true);
+		expect(apputil.print.calls.count()).toEqual(0);
+		expect(apputil.print.calls.allArgs()).toEqual([  ]);
+		expect(superspawn.spawn.calls.argsFor(0)[2]).toEqual(Object({ stdio: 'default' }));
+	},TIMEOUT);
+
+	it("Test#003 : Print command and output", function () {
+		executil.execHelper([ 'git', 'symbolic-ref', 'HEAD' ], false, true);
+		expect(apputil.print.calls.count()).toEqual(1);
+		expect(apputil.print.calls.argsFor(0)[0]).toEqual('Executing:');
+		expect(apputil.print.calls.argsFor(0)[1]).toEqual('git symbolic-ref HEAD');
+		expect(superspawn.spawn.calls.argsFor(0)[2]).toEqual(Object({ stdio: 'inherit' }));
+	},TIMEOUT);
+
+	it("Test#004 : Don't print command, print output", function () {
+		executil.execHelper([ 'git', 'symbolic-ref', 'HEAD' ], 2, true);
+		expect(apputil.print.calls.count()).toEqual(0);
+		expect(superspawn.spawn.calls.argsFor(0)[2]).toEqual(Object({ stdio: 'inherit' }));
+	},TIMEOUT);
+
+	it("Test#005 : Print command, don't print output", function () {
+		executil.execHelper([ 'git', 'symbolic-ref', 'HEAD' ], 3, true);
+		expect(apputil.print.calls.count()).toEqual(1);
+		expect(apputil.print.calls.argsFor(0)[0]).toEqual('Executing:');
+		expect(apputil.print.calls.argsFor(0)[1]).toEqual('git symbolic-ref HEAD');
+		expect(superspawn.spawn.calls.argsFor(0)[2]).toEqual(Object({ stdio: 'default' }));
+	},TIMEOUT);
+
+	it("Test#006 : pretending to run", function* () {
+		var executilExecOrPretend = yield executil.execOrPretend([ 'git', 'symbolic-ref', 'HEAD'
], 'pretend');
+		expect(apputil.print.calls.count()).toEqual(1);
+		expect(apputil.print.calls.argsFor(0)[0]).toEqual('PRETENDING TO RUN: git symbolic-ref
HEAD');
+	},TIMEOUT);
+});
\ No newline at end of file
diff --git a/spec/flagutil.spec.js b/spec/flagutil.spec.js
new file mode 100644
index 0000000..be266dd
--- /dev/null
+++ b/spec/flagutil.spec.js
@@ -0,0 +1,75 @@
+/*
+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 path = require('path');
+var apputil = require('../src/apputil');
+var repoutil = require('../src/repoutil');
+var flagutil = require('../src/flagutil');
+var TIMEOUT = 60000;
+
+describe("flagutil unit tests", function () {
+
+	it("Test#001 : validate the version that is passed in", function () {
+		spyOn(console,"log").and.returnValue(false);
+		spyOn(apputil, "fatal");
+		flagutil.validateVersionString('6.3.0');
+		expect(flagutil.validateVersionString('6.3.0')).toEqual('6.3.0');
+		expect(apputil.fatal.calls.count()).toEqual(0);
+	},TIMEOUT);
+
+	it("Test#002 : computeReposFromFlag returns correct repo (platform) info", function () {
+		var repo = flagutil.computeReposFromFlag('android');
+		expect(repo).toEqual(
+			[ Object({ 
+			title: 'Android', 
+			id: 'android', 
+			repoName: 'cordova-android', 
+			jiraComponentName: 'Android', 
+			cordovaJsPaths: [ 'bin/templates/project/assets/www/cordova.js' ] }) ]
+		);
+	},TIMEOUT);
+
+	it("Test#003 : computeReposFromFlag returns correct repo (plugin) info", function () {
+		var repo = flagutil.computeReposFromFlag('plugin-camera');
+		expect(repo).toEqual(
+		[ { title: 'Plugin - Camera',
+		    id: 'plugin-camera',
+		    repoName: 'cordova-plugin-camera',
+		    jiraComponentName: 'Plugin Camera' } ]
+		);
+	},TIMEOUT);
+
+	it("Test#004 : computeReposFromFlag returns correct repo (docs) info", function () {
+		var repo = flagutil.computeReposFromFlag('docs');
+		expect(repo).toEqual(
+		[ { title: 'Docs',
+		    id: 'docs',
+		    repoName: 'cordova-docs',
+		    jiraComponentName: 'Docs' } ]
+		);
+	},TIMEOUT);
+
+	it("Test#005 : passing in a non-repo is invalid", function () {
+		spyOn(apputil, "fatal");
+		var nonRepo = flagutil.computeReposFromFlag('nonRepo');
+		expect(apputil.fatal.calls.count()).toEqual(1);
+		expect(apputil.fatal.calls.argsFor(0)[0]).toMatch('Invalid repo value: nonRepo');
+	},TIMEOUT);
+});
+
diff --git a/spec/gitutil.spec.js b/spec/gitutil.spec.js
new file mode 100644
index 0000000..fbdb199
--- /dev/null
+++ b/spec/gitutil.spec.js
@@ -0,0 +1,77 @@
+/*
+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 jasmine_co = require('jasmine-co').install();
+var path = require('path');
+var executil = require('../src/executil');
+var gitutilJS = require('../src/gitutil');
+var gitutil = exports;
+var semver = require('semver');
+var TIMEOUT = 60000;
+var androidRepo = { title: 'Android', 
+	id: 'android',
+	repoName: 'cordova-android',
+	jiraComponentName: 'Android',
+	cordovaJsPaths: [ 'bin/templates/project/assets/www/cordova.js' ],
+	remoteName: 'origin' };
+
+describe("gitutil unit tests", function () {
+	beforeEach(function* () {
+		spyOn(executil,'execHelper').and.callFake(function() {
+			return function* (){return true};
+		});
+		spyOn(executil,'ARGS').and.callFake(function() {
+			return function* (){return true};
+		});
+	});
+	it("Test#001 : validate the version that is passed in", function* () {
+		var gitutilTagExists = yield gitutilJS.tagExists('6.3.0');
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.argsFor(0)[0]).toEqual("git tag --list 6.3.0");
+	},TIMEOUT);
+
+	it("Test#002 : validate remote branch", function* () {
+		var gitutilRemoteBranch = yield gitutilJS.remoteBranchExists('android', 'name');
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.argsFor(0)[0]).toEqual("git branch -r --list undefined/name");
+	},TIMEOUT);
+
+	it("Test#003 : validate pending changes", function* () {
+		var gitutilPendingChanges = yield gitutilJS.pendingChangesExist();
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.argsFor(0)[0]).toEqual("git status --porcelain");
+	},TIMEOUT);
+
+	it("Test#004 : reseting from origin", function* () {
+		var gitutilReset = yield gitutilJS.resetFromOrigin();
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.argsFor(0)[0]).toEqual("git reset --hard origin/master");
+	},TIMEOUT);
+
+	it("Test#005 : git clean", function* () {
+		var gitutilClean = yield gitutilJS.gitClean();
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.count()).toEqual(1);
+		expect(executil.ARGS.calls.argsFor(0)[0]).toEqual("git clean -d -f");
+	},TIMEOUT);
+});
\ No newline at end of file
diff --git a/spec/repoutil.spec.js b/spec/repoutil.spec.js
new file mode 100644
index 0000000..fce8e82
--- /dev/null
+++ b/spec/repoutil.spec.js
@@ -0,0 +1,84 @@
+/*
+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 jasmine_co = require('jasmine-co').install();
+var fs = require('fs');
+var path = require('path');
+var shelljs = require('shelljs');
+var apputil = require('../src/apputil');
+var repoutil = require('../src/repoutil');
+var TIMEOUT = 60000;
+var androidRepo = { title: 'Android', 
+	id: 'android',
+	repoName: 'cordova-android',
+	jiraComponentName: 'Android',
+	cordovaJsPaths: [ 'bin/templates/project/assets/www/cordova.js' ],
+	remoteName: 'origin' };
+var commonRepo = {
+    title: 'Cordova Common',
+    id: 'common',
+    packageName: 'cordova-common',
+    repoName: 'cordova-lib',
+    path: 'cordova-common',
+    versionPrefix: 'common',
+    isModule: true };
+
+describe("check functionality of repoutil", function () {
+	it("Test#001 : getRepoDir", function () {
+		spyOn(apputil, "getBaseDir").and.returnValue('path');
+		spyOn(path, "join").and.returnValue(true);
+		repoutil.getRepoDir(commonRepo);
+		expect(apputil.getBaseDir.calls.count()).toEqual(1);
+		expect(path.join.calls.count()).toEqual(2);
+	},TIMEOUT);
+
+	it("Test#002 : repo listed in group, should be true", function () {
+		repoutil.isInRepoGroup(androidRepo, 'platform');
+		expect(repoutil.isInRepoGroup(androidRepo, 'platform')).toEqual(true);
+	},TIMEOUT);
+
+	it("Test#003 : repo not listed in group, should be false", function () {
+		repoutil.isInRepoGroup(commonRepo, 'platform');
+		expect(repoutil.isInRepoGroup(commonRepo, 'platform')).toEqual(false);
+	},TIMEOUT);
+
+	it("Test#004 : testing proper calls are made for forEachRepo function", function* (){
+		spyOn(shelljs , "cd").and.returnValue(true);
+		spyOn(shelljs, "error");
+		spyOn(apputil, "fatal");
+		var x = yield repoutil.forEachRepo([repoutil.getRepoById('coho')], function* () {});
+		expect(shelljs.cd.calls.count()).toEqual(2);
+		expect(shelljs.error.calls.count()).toEqual(1);
+		expect(apputil.fatal.calls.count()).toEqual(0);
+	},TIMEOUT);
+
+    it("Test#005 : getRepoById should return correct repo object ", function () {
+        // Return correct repo object
+        repoutil.getRepoById('cordova-android');
+        expect(repoutil.getRepoById('cordova-android')).toEqual(Object(
+	        { title: 'Android', id: 'android', 
+	        repoName: 'cordova-android', 
+	        jiraComponentName: 'Android', 
+	        cordovaJsPaths: [ 'bin/templates/project/assets/www/cordova.js' ] }
+        ));
+        // Return null if opt repos are passed in
+        repoutil.getRepoById('cordova-android', 'opt_repos');
+        expect(repoutil.getRepoById('cordova-android', 'opt_repos')).toEqual(null);
+    },TIMEOUT); 
+});
diff --git a/spec/versionutil.spec.js b/spec/versionutil.spec.js
new file mode 100644
index 0000000..2679f29
--- /dev/null
+++ b/spec/versionutil.spec.js
@@ -0,0 +1,149 @@
+/*
+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 versionutil = require("../src/versionutil");
+var jasmine_co = require('jasmine-co').install();
+var fs = require('fs');
+var path = require('path');
+var shell = require('shelljs');
+var repoutil = require('../src/repoutil');
+var executil = require('../src/executil');
+var gitutil = require('../src/gitutil');
+var apputil = require('../src/apputil');
+var TIMEOUT = 60000;
+var androidRepo = { title: 'Android', 
+	id: 'android',
+	repoName: 'cordova-android',
+	jiraComponentName: 'Android',
+	cordovaJsPaths: [ 'bin/templates/project/assets/www/cordova.js' ],
+	remoteName: 'origin' };
+var iosRepo = { title: 'iOS',
+    id: 'ios',
+    repoName: 'cordova-ios',
+    jiraComponentName: 'iOS',
+    cordovaJsPaths: ['CordovaLib/cordova.js'],
+    versionFilePaths: [path.join('CordovaLib', 'VERSION')]};
+var windowsRepo = { title: 'Windows',
+    id: 'windows',
+    repoName: 'cordova-windows',
+    jiraComponentName: 'Windows 8',
+    cordovaJsSrcName: 'cordova.windows.js',
+    cordovaJsPaths: ['template/www/cordova.js'],
+    versionFilePaths: ['VERSION'],
+    packageFilePaths: ['package.json']};
+var browserRepo = { title: 'Browser',
+        id: 'browser',
+        repoName: 'cordova-browser',
+        jiraComponentName: 'Browser',
+        cordovaJsSrcName: 'cordova.browser.js',
+        cordovaJsPaths: ['cordova-lib/cordova.js']};
+
+describe("Correct version is passed to gradle.build", function () {
+	var shellSpy;
+	beforeEach(function* () {
+		spyOn(fs, 'writeFileSync').and.returnValue(true);
+		spyOn(fs, 'readFile').and.returnValue(true);
+		spyOn(fs,'existsSync').and.returnValue(true);
+		shellSpy = spyOn(shell,'sed').and.returnValue(true);
+		spyOn(apputil, 'print').and.returnValue(true);
+		spyOn(repoutil, 'isInRepoGroup').and.returnValue(true);
+		spyOn(gitutil, 'pendingChangesExist').and.callFake(function() {
+			return function* (){return true};
+		});
+		spyOn(executil,'execHelper').and.callFake(function() {
+			return function* (){return true};
+		});
+	});
+
+	afterEach(function () {
+		fs.writeFileSync.calls.reset();
+		fs.readFile.calls.reset();
+		fs.existsSync.calls.reset();
+		shell.sed.calls.reset();
+		apputil.print.calls.reset();
+		repoutil.isInRepoGroup.calls.reset();
+		gitutil.pendingChangesExist.calls.reset();
+		executil.execHelper.calls.reset();
+	});
+
+	it("Test#001 : checks that the correct android version is passed in", function* () {
+		var androidVersion = yield versionutil.updateRepoVersion(androidRepo, "6.4.0-dev");
+		// Check call count
+		expect(fs.writeFileSync.calls.count()).toEqual(1);
+		expect(fs.existsSync.calls.count()).toEqual(2);
+		expect(fs.readFile.calls.count()).toEqual(1);
+		expect(repoutil.isInRepoGroup.calls.count()).toEqual(1);
+		expect(repoutil.isInRepoGroup.calls.count()).toEqual(1);
+		expect(gitutil.pendingChangesExist.calls.count()).toEqual(3);
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		expect(apputil.print.calls.count()).toEqual(0);
+		expect(shell.sed.calls.count()).toEqual(5);
+		// Check that args are correct
+		expect(shell.sed.calls.argsFor(0)[2]).toEqual('CORDOVA_VERSION = "6.4.0-dev";');
+		expect(shell.sed.calls.argsFor(1)[2]).toEqual('VERSION = "6.4.0-dev";');
+		expect(shell.sed.calls.argsFor(2)[2]).toEqual("version = '6.4.0-dev'");
+		expect(shell.sed.calls.argsFor(3)[2]).toEqual("vcsTag = '6.4.0-dev'");
+		expect(shell.sed.calls.argsFor(4)[2]).toContain("name = '6.4.0-dev");
+	},TIMEOUT);
+
+	it("Test#002 : checks that the correct ios version is passed in", function* () {
+		var iosVersion = yield versionutil.updateRepoVersion(iosRepo, "4.2.0-dev");
+		// Check call count
+		expect(fs.writeFileSync.calls.count()).toEqual(1);
+		expect(fs.existsSync.calls.count()).toEqual(2);
+		expect(repoutil.isInRepoGroup.calls.count()).toEqual(1);
+		expect(fs.readFile.calls.count()).toEqual(1);
+		expect(gitutil.pendingChangesExist.calls.count()).toEqual(3);
+		expect(shell.sed.calls.count()).toEqual(1);
+		expect(apputil.print.calls.count()).toEqual(0);
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		// Check that args are correct
+		expect(shell.sed.calls.argsFor(0)[2]).toEqual('VERSION="4.2.0-dev";');
+	},TIMEOUT);
+
+	it("Test#003 : checks that the correct windows version is passed in", function* () {
+		var windowsVersion = yield versionutil.updateRepoVersion(windowsRepo, "4.5.0-dev");
+		// Check call count
+		expect(fs.writeFileSync.calls.count()).toEqual(1);
+		expect(fs.existsSync.calls.count()).toEqual(3);
+		expect(repoutil.isInRepoGroup.calls.count()).toEqual(1);
+		expect(gitutil.pendingChangesExist.calls.count()).toEqual(3);
+		expect(fs.readFile.calls.count()).toEqual(1);
+		expect(shell.sed.calls.count()).toEqual(1);
+		expect(apputil.print.calls.count()).toEqual(0);
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		// Check that args are correct
+		expect(shell.sed.calls.argsFor(0)[2]).toEqual('VERSION = "4.5.0-dev";');
+	},TIMEOUT);
+
+	it("Test#004 : check that the correct browser version is passed in", function* () {
+		var browserVersion = yield versionutil.updateRepoVersion(browserRepo, "4.1.0-dev");
+		//Check call count
+		expect(fs.writeFileSync.calls.count()).toEqual(1);
+		expect(fs.existsSync.calls.count()).toEqual(2);
+		expect(repoutil.isInRepoGroup.calls.count()).toEqual(1);
+		expect(gitutil.pendingChangesExist.calls.count()).toEqual(3);
+		expect(fs.readFile.calls.count()).toEqual(1);
+		expect(shell.sed.calls.count()).toEqual(1);
+		expect(apputil.print.calls.count()).toEqual(0);
+		expect(executil.execHelper.calls.count()).toEqual(1);
+		// Check that args are correct
+		expect(shell.sed.calls.argsFor(0)[2]).toEqual('VERSION = "4.1.0-dev";');
+	},TIMEOUT);
+});
\ No newline at end of file
diff --git a/src/executil.js b/src/executil.js
index fd5838e..e461d0d 100644
--- a/src/executil.js
+++ b/src/executil.js
@@ -19,7 +19,6 @@ under the License.
 
 var apputil = require('./apputil');
 var superspawn = require('./superspawn');
-var print = apputil.print;
 
 var gitCommitCount = 0;
 
@@ -51,14 +50,14 @@ function execHelper (cmdAndArgs, silent, allowError, win, fail) {
     }
     cmdAndArgs[0] = cmdAndArgs[0].replace(/^git /, 'git -c color.ui=always ');
     if (!silent || silent === 3 || exports.verbose) {
-        print('Executing:', cmdAndArgs.join(' '));
+        apputil.print('Executing:', cmdAndArgs.join(' '));
     }
     var result = superspawn.spawn(cmdAndArgs[0], cmdAndArgs.slice(1), {stdio: (silent &&
(silent !== 2)) ? 'default' : 'inherit'});
     return result.then(win || null, fail || function (e) {
         if (allowError) {
             throw e;
         } else if (+silent !== 1) {
-            print(e.output);
+            apputil.print(e.output);
         }
         process.exit(2);
     });
@@ -66,18 +65,18 @@ function execHelper (cmdAndArgs, silent, allowError, win, fail) {
 exports.execHelper = execHelper;
 
 function reportGitPushResult (repos, branches) {
-    print('');
+    apputil.print('');
     if (gitCommitCount) {
         var flagsStr = repos.map(function (r) { return '-r ' + r.id; }).join(' ') + ' ' +
branches.map(function (b) { return '-b ' + b; }).join(' ');
-        print('All work complete. ' + gitCommitCount + ' commits were made locally.');
-        print('To review changes:');
-        print('  ' + process.argv[1] + ' repo-status ' + flagsStr + ' --diff | less');
-        print('To push changes:');
-        print('  ' + process.argv[1] + ' repo-push ' + flagsStr);
-        print('To revert all local commits:');
-        print('  ' + process.argv[1] + ' repo-reset ' + flagsStr);
+        apputil.print('All work complete. ' + gitCommitCount + ' commits were made locally.');
+        apputil.print('To review changes:');
+        apputil.print('  ' + process.argv[1] + ' repo-status ' + flagsStr + ' --diff | less');
+        apputil.print('To push changes:');
+        apputil.print('  ' + process.argv[1] + ' repo-push ' + flagsStr);
+        apputil.print('To revert all local commits:');
+        apputil.print('  ' + process.argv[1] + ' repo-reset ' + flagsStr);
     } else {
-        print('All work complete. No commits were made.');
+        apputil.print('All work complete. No commits were made.');
     }
 }
 
@@ -85,7 +84,7 @@ exports.reportGitPushResult = reportGitPushResult;
 
 function * execOrPretend (cmd, pretend) {
     if (pretend) {
-        print('PRETENDING TO RUN: ' + cmd.join(' '));
+        apputil.print('PRETENDING TO RUN: ' + cmd.join(' '));
     } else {
         return yield execHelper(cmd);
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message