cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject android commit: Start of GradleBuilder.js specs - puts it on the code coverage radar.
Date Tue, 02 May 2017 22:34:04 GMT
Repository: cordova-android
Updated Branches:
  refs/heads/master ee1165ea3 -> 9d9abea15


Start of GradleBuilder.js specs - puts it on the code coverage radar.


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

Branch: refs/heads/master
Commit: 9d9abea157888f7919f23a4e50fa2685b3ba2008
Parents: ee1165e
Author: filmaj <maj.fil@gmail.com>
Authored: Tue May 2 14:42:50 2017 -0700
Committer: Joe Bowser <bowserj@apache.org>
Committed: Tue May 2 15:31:26 2017 -0700

----------------------------------------------------------------------
 .../cordova/lib/builders/GradleBuilder.js       |  8 +++----
 spec/unit/builders/GradleBuilder.spec.js        | 25 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/9d9abea1/bin/templates/cordova/lib/builders/GradleBuilder.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/builders/GradleBuilder.js b/bin/templates/cordova/lib/builders/GradleBuilder.js
index 5b5ce13..0d32d56 100644
--- a/bin/templates/cordova/lib/builders/GradleBuilder.js
+++ b/bin/templates/cordova/lib/builders/GradleBuilder.js
@@ -22,7 +22,7 @@ var fs = require('fs');
 var util = require('util');
 var path = require('path');
 var shell = require('shelljs');
-var spawn = require('cordova-common').superspawn.spawn;
+var superspawn = require('cordova-common').superspawn;
 var CordovaError = require('cordova-common').CordovaError;
 var check_reqs = require('../check_reqs');
 
@@ -75,7 +75,7 @@ GradleBuilder.prototype.runGradleWrapper = function(gradle_cmd) {
     if(fs.existsSync(gradlePath)) {
       //Literally do nothing, for some reason this works, while !fs.existsSync didn't on
Windows
     } else {
-      return spawn(gradle_cmd, ['-p', this.root, 'wrapper', '-b', wrapperGradle], {stdio:
'inherit'});
+      return superspawn.spawn(gradle_cmd, ['-p', this.root, 'wrapper', '-b', wrapperGradle],
{stdio: 'inherit'});
     }
 };
 
@@ -223,7 +223,7 @@ GradleBuilder.prototype.build = function(opts) {
     var wrapper = path.join(this.root, 'gradlew');
     var args = this.getArgs(opts.buildType == 'debug' ? 'debug' : 'release', opts);
 
-    return spawn(wrapper, args, {stdio: 'pipe'})
+    return superspawn.spawn(wrapper, args, {stdio: 'pipe'})
     .progress(function (stdio){
         if (stdio.stderr) {
             /*
@@ -258,7 +258,7 @@ GradleBuilder.prototype.clean = function(opts) {
     var wrapper = path.join(this.root, 'gradlew');
     var args = builder.getArgs('clean', opts);
     return Q().then(function() {
-        return spawn(wrapper, args, {stdio: 'inherit'});
+        return superspawn.spawn(wrapper, args, {stdio: 'inherit'});
     })
     .then(function () {
         shell.rm('-rf', path.join(builder.root, 'out'));

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/9d9abea1/spec/unit/builders/GradleBuilder.spec.js
----------------------------------------------------------------------
diff --git a/spec/unit/builders/GradleBuilder.spec.js b/spec/unit/builders/GradleBuilder.spec.js
new file mode 100644
index 0000000..28652bd
--- /dev/null
+++ b/spec/unit/builders/GradleBuilder.spec.js
@@ -0,0 +1,25 @@
+var gradle_builder = require('../../../bin/templates/cordova/lib/builders/GradleBuilder.js');
+var fs = require('fs');
+var superspawn = require('cordova-common').superspawn;
+var builder;
+
+describe('Gradle Builder', function() {
+    beforeEach(function() {
+        spyOn(fs, 'existsSync').and.returnValue(true);
+        builder = new gradle_builder('/root');
+        spyOn(superspawn, 'spawn');
+    });
+
+    describe('runGradleWrapper method', function() {
+        it('should run the provided gradle command if a gradle wrapper does not already exist',
function() {
+            fs.existsSync.and.returnValue(false);
+            builder.runGradleWrapper('/my/sweet/gradle');
+            expect(superspawn.spawn).toHaveBeenCalledWith('/my/sweet/gradle', jasmine.any(Array),
jasmine.any(Object));
+        });
+        it('should do nothing if a gradle wrapper exists in the project directory', function()
{
+            fs.existsSync.and.returnValue(true);
+            builder.runGradleWrapper('/my/sweet/gradle');
+            expect(superspawn.spawn).not.toHaveBeenCalledWith('/my/sweet/gradle', jasmine.any(Array),
jasmine.any(Object));
+        });
+    });
+});


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


Mime
View raw message