You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/04/25 07:40:29 UTC

git commit: ios resource and framework tests.

Updated Branches:
  refs/heads/master a1bd0e843 -> 83e985883


ios resource and framework tests.


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

Branch: refs/heads/master
Commit: 83e985883e78578489773ddc3483c018e7046ba1
Parents: a1bd0e8
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Apr 24 22:40:22 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Wed Apr 24 22:40:22 2013 -0700

----------------------------------------------------------------------
 README.md                            |    2 -
 spec/platforms/ios.spec.js           |   58 +++++++++++++++++++++++++----
 spec/plugins/DummyPlugin/plugin.xml  |    1 +
 spec/plugins/FaultyPlugin/plugin.xml |    1 +
 src/platforms/ios.js                 |    3 +-
 5 files changed, 53 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/83e98588/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 32188db..75e83a9 100644
--- a/README.md
+++ b/README.md
@@ -365,8 +365,6 @@ plugman identifies the framework through the `src` attribute and attempts to add
 
 The optional `weak` attribute is a boolean denoting whether the framework should be weakly-linked. Default is `false`.
 
-If the file specified by `src` does not exist, the tool should stop/reverse the installation process, warn the user, and exit with a non-zero code.
-
 ### &lt;dependencies&gt; and &lt;dependency&gt;
 
 Identifies dependency of the plugin on another plugin.

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/83e98588/spec/platforms/ios.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/ios.spec.js b/spec/platforms/ios.spec.js
index e082ce5..6097da4 100644
--- a/spec/platforms/ios.spec.js
+++ b/spec/platforms/ios.spec.js
@@ -28,6 +28,7 @@ var valid_source = platformTag.findall('./source-file'),
     assets = plugin_et.findall('./asset'),
     valid_headers = platformTag.findall('./header-file'),
     valid_resources = platformTag.findall('./resource-file'),
+    valid_frameworks = platformTag.findall('./framework'),
     plist_els = platformTag.findall('./plugins-plist'),
     dummy_configs = platformTag.findall('./config-file');
 
@@ -48,6 +49,7 @@ var faulty_id = plugin_et._root.attrib['id'];
 var invalid_source = platformTag.findall('./source-file');
 var invalid_headers = platformTag.findall('./header-file');
 var invalid_resources = platformTag.findall('./resource-file');
+var invalid_frameworks = platformTag.findall('./framework');
 
 xml_path = path.join(plistplugin, 'plugin.xml');
 xml_test = fs.readFileSync(xml_path, 'utf-8');
@@ -283,7 +285,7 @@ describe('ios project handler', function() {
                     ios.install(resources, faulty_id, temp, faultyplugin, {});
                 }).toThrow('cannot find "' + path.resolve(faultyplugin, 'src/ios/IDontExist.bundle') + '" ios <resource-file>');
             });
-            it('should throw if resrouce-file target already exists', function() {
+            it('should throw if resource-file target already exists', function() {
                 var resources = copyArray(valid_resources);
                 var target = path.join(temp, 'SampleApp', 'Resources', 'DummyPlugin.bundle');
                 fs.writeFileSync(target, 'some bs', 'utf-8');
@@ -291,16 +293,56 @@ describe('ios project handler', function() {
                     ios.install(resources, dummy_id, temp, dummyplugin, {});
                 }).toThrow('target destination "' + target + '" already exists');
             });
-            it('should throw if resource-file src cannot be found');
-            it('should throw if resource-file target already exists');
-            it('should call into xcodeproj\'s addResourceFile');
-            it('should cp the file to the right target location');
+            it('should call into xcodeproj\'s addResourceFile', function() {
+                var resources = copyArray(valid_resources);
+                var spy = jasmine.createSpy();
+                spyOn(xcode, 'project').andReturn({
+                    parseSync:function(){},
+                    writeSync:function(){},
+                    addResourceFile:spy
+                });
+                ios.install(resources, dummy_id, temp, dummyplugin, {});
+                expect(spy).toHaveBeenCalledWith(path.join('Resources', 'DummyPlugin.bundle'));
+            });
+            it('should cp the file to the right target location', function() {
+                var resources = copyArray(valid_resources);
+                spyOn(xcode, 'project').andReturn({
+                    parseSync:function(){},
+                    writeSync:function(){},
+                    addResourceFile:function() {}
+                });
+                var spy = spyOn(shell, 'cp');
+                ios.install(resources, dummy_id, temp, dummyplugin, {});
+                expect(spy).toHaveBeenCalledWith('-R', path.join(dummyplugin, 'src', 'ios', 'DummyPlugin.bundle'), path.join(temp, 'SampleApp', 'Resources'));
+            });
         });
 
         describe('of <framework> elements', function() {
-            it('should throw if framework src cannot be found');
-            it('should call into xcodeproj\'s addFramework');
-            it('should pass in whether the framework is weak or not into xcodeproj');
+            beforeEach(function() {
+                shell.cp('-rf', ios_config_xml_project, temp);
+            });
+            it('should call into xcodeproj\'s addFramework with weak false by default' ,function() {
+                var frameworks = copyArray(valid_frameworks).filter(function(f) { return f.attrib.weak == undefined; });
+                var spy = jasmine.createSpy();
+                spyOn(xcode, 'project').andReturn({
+                    parseSync:function(){},
+                    writeSync:function(){},
+                    addFramework:spy
+                });
+                ios.install(frameworks, dummy_id, temp, dummyplugin, {});
+                expect(spy).toHaveBeenCalledWith(path.join('src', 'ios', 'libsqlite3.dylib'), {weak:false});
+            });
+            it('should pass in whether the framework is weak or not to xcodeproj.addFramework', function() {
+                var frameworks = copyArray(valid_frameworks).filter(function(f) { return f.attrib.weak != undefined; });;
+                var spy = jasmine.createSpy();
+                spyOn(xcode, 'project').andReturn({
+                    parseSync:function(){},
+                    writeSync:function(){},
+                    addFramework:spy
+                });
+                ios.install(frameworks, dummy_id, temp, dummyplugin, {});
+                expect(spy).toHaveBeenCalledWith(path.join('src', 'ios', 'libsqlite3.dylib'), {weak:true});
+            });
         });
     });
 

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/83e98588/spec/plugins/DummyPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/DummyPlugin/plugin.xml b/spec/plugins/DummyPlugin/plugin.xml
index 21845e7..06b99eb 100644
--- a/spec/plugins/DummyPlugin/plugin.xml
+++ b/spec/plugins/DummyPlugin/plugin.xml
@@ -94,5 +94,6 @@
 
         <!-- framework for testing (not actual dependency of DummyPlugin -->
         <framework src="src/ios/libsqlite3.dylib" />
+        <framework src="src/ios/libsqlite3.dylib" weak="true" />
     </platform>
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/83e98588/spec/plugins/FaultyPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/FaultyPlugin/plugin.xml b/spec/plugins/FaultyPlugin/plugin.xml
index b556e9d..728a03b 100644
--- a/spec/plugins/FaultyPlugin/plugin.xml
+++ b/spec/plugins/FaultyPlugin/plugin.xml
@@ -70,6 +70,7 @@
         <header-file src="src/ios/FaultyPluginCommand.h" />
         <source-file src="src/ios/FaultyPluginCommand.m" />
         <resource-file src="src/ios/IDontExist.bundle" />
+        <framework src="src/ios/Nopers.lib" />
     </platform>
     <platform name="blackberry">
         <config-file target="config.xml" parent="/widget">

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/83e98588/src/platforms/ios.js
----------------------------------------------------------------------
diff --git a/src/platforms/ios.js b/src/platforms/ios.js
index a5db1fd..59495db 100644
--- a/src/platforms/ios.js
+++ b/src/platforms/ios.js
@@ -233,8 +233,7 @@ function handlePlugin(action, plugin_id, txs, project_dir, plugin_dir, variables
                     var src = mod.attrib['src'],
                         weak = mod.attrib['weak'];
                     if (action == 'install') {
-                        // TODO: check for src existence/collision?
-                        var opt = { weak: (weak && weak.toLowerCase() == 'true') };
+                        var opt = { weak: (weak == undefined || weak == null || weak != 'true' ? false : true ) };
                         xcodeproj.addFramework(src, opt);
                     } else {
                         xcodeproj.removeFramework(src);