You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2019/11/12 16:40:39 UTC

[cordova-node-xcode] branch master updated: Add target test coverage (#82)

This is an automated email from the ASF dual-hosted git repository.

brodybits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-node-xcode.git


The following commit(s) were added to refs/heads/master by this push:
     new 8307518  Add target test coverage (#82)
8307518 is described below

commit 83075188e984e09ca11ca2484c54494ac9348ed5
Author: l3ender <l3...@users.noreply.github.com>
AuthorDate: Tue Nov 12 10:40:31 2019 -0600

    Add target test coverage (#82)
    
    * addTarget coverage - target name
    
    * addTarget coverage - validate target type
    
    * addTarget coverage - build configuration validation
    
    * addTarget coverage - target name
    
    * addTarget coverage - target type/name error validation
    
    * addTarget coverage - strict match for build config comment
    
    * addTarget coverage - debug/release build config
---
 test/addTarget.js | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)

diff --git a/test/addTarget.js b/test/addTarget.js
index 02b41bb..6e44625 100644
--- a/test/addTarget.js
+++ b/test/addTarget.js
@@ -42,9 +42,35 @@ exports.addTarget = {
 
         test.done();
     },
+    'should throw when provided blank or empty target name': function (test) {
+        test.throws(function() {
+            proj.addTarget('', TARGET_TYPE);
+        }, function (error) {
+            return (error instanceof Error) && /Target name missing/i.test(error);
+        });
+
+        test.throws(function() {
+            proj.addTarget('   ', TARGET_TYPE);
+        }, function (error) {
+            return (error instanceof Error) && /Target name missing/i.test(error);
+        });
+
+        test.done();
+    },
     'should throw when target type missing': function (test) {
         test.throws(function() {
             proj.addTarget(TARGET_NAME, null);
+        }, function (error) {
+            return (error instanceof Error) && /Target type missing/i.test(error);
+        });
+
+        test.done();
+    },
+    'should throw when invalid target type': function (test) {
+        test.throws(function() {
+            proj.addTarget(TARGET_NAME, 'invalid_target_type');
+        }, function (error) {
+            return (error instanceof Error) && /Target type invalid/i.test(error);
         });
 
         test.done();
@@ -67,6 +93,60 @@ exports.addTarget = {
 
         test.done();
     },
+    'should add debug and release configurations to build configuration list': function (test) {
+        var pbxXCBuildConfigurationSection = proj.pbxXCBuildConfigurationSection(),
+            pbxXCConfigurationList = proj.pbxXCConfigurationList(),
+            target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME);
+
+        test.ok(target.pbxNativeTarget.buildConfigurationList);
+        test.ok(pbxXCConfigurationList[target.pbxNativeTarget.buildConfigurationList]);
+        var buildConfigurations = pbxXCConfigurationList[target.pbxNativeTarget.buildConfigurationList].buildConfigurations;
+        test.ok(buildConfigurations);
+        test.equal(buildConfigurations.length, 2);
+
+        buildConfigurations.forEach((config, index) => {
+            var configUuid = config.value;
+            test.ok(configUuid);
+            var pbxConfig = pbxXCBuildConfigurationSection[configUuid];
+            test.ok(pbxConfig);
+            test.equal(pbxConfig.name, index === 0 ? 'Debug' : 'Release');
+            test.equal(pbxConfig.isa, 'XCBuildConfiguration');
+            test.ok(pbxConfig.buildSettings);
+            if (index === 0) {
+                var debugConfig = pbxConfig.buildSettings['GCC_PREPROCESSOR_DEFINITIONS'];
+                test.ok(debugConfig);
+                test.equal(debugConfig.length, 2);
+                test.equal(debugConfig[0], '"DEBUG=1"');
+                test.equal(debugConfig[1], '"$(inherited)"');
+            }
+            test.equal(pbxConfig.buildSettings['INFOPLIST_FILE'], '"' + TARGET_SUBFOLDER_NAME + '/' + TARGET_SUBFOLDER_NAME + '-Info.plist"');
+            test.equal(pbxConfig.buildSettings['LD_RUNPATH_SEARCH_PATHS'], '"$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"');
+            test.equal(pbxConfig.buildSettings['PRODUCT_NAME'], '"' + TARGET_NAME + '"');
+            test.equal(pbxConfig.buildSettings['SKIP_INSTALL'], 'YES');
+        });
+
+        test.done();
+    },
+    'should add to build configuration list with default configuration name': function (test) {
+        var pbxXCConfigurationList = proj.pbxXCConfigurationList(),
+            target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME);
+
+        test.ok(target.pbxNativeTarget.buildConfigurationList);
+        test.ok(pbxXCConfigurationList[target.pbxNativeTarget.buildConfigurationList]);
+        test.equal(pbxXCConfigurationList[target.pbxNativeTarget.buildConfigurationList].defaultConfigurationName, 'Release');
+
+        test.done();
+    },
+    'should add to build configuration list with comment': function (test) {
+        var pbxXCConfigurationList = proj.pbxXCConfigurationList(),
+            target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME);
+
+        var buildCommentKey = target.pbxNativeTarget.buildConfigurationList + '_comment';
+        test.ok(pbxXCConfigurationList[buildCommentKey]);
+        test.equals(pbxXCConfigurationList[buildCommentKey], 'Build configuration list for PBXNativeTarget "' + TARGET_NAME + '"');
+
+        test.done();
+    },
     'should create a new target and add source, framework, resource and header files and the corresponding build phases': function (test) {
         var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME),
             options = { 'target' : target.uuid };
@@ -103,6 +183,15 @@ exports.addTarget = {
 
         test.done();
     },
+    'should create target with correct pbxNativeTarget name': function (test) {
+        var target = proj.addTarget(TARGET_NAME, TARGET_TYPE, TARGET_SUBFOLDER_NAME);
+
+        var quotedTargetName = '"' + TARGET_NAME + '"';
+        test.equals(target.pbxNativeTarget.name, quotedTargetName);
+        test.equals(target.pbxNativeTarget.productName, quotedTargetName);
+
+        test.done();
+    },
     'should add build phase for extension target': function (test) {
         var target = proj.addTarget(TARGET_NAME, TARGET_TYPE);
         test.ok(target.uuid);


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