Skip to content

Internal pbxProject.prototype.addTargetDependency function not properly tested #74

@brody4hire

Description

@brody4hire

As discovered through Stryker mutation testing (PR #61), the following changes to pbxProject.prototype.addTargetDependency do not seem to trigger a test failure:

diff --git a/lib/pbxProject.js b/lib/pbxProject.js
index be9f473..74b5f08 100644
--- a/lib/pbxProject.js
+++ b/lib/pbxProject.js
@@ -820,15 +820,6 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
 
     var nativeTargets = this.pbxNativeTargetSection();
 
-    if (typeof nativeTargets[target] == "undefined")
-        throw new Error("Invalid target: " + target);
-
-    for (var index = 0; index < dependencyTargets.length; index++) {
-        var dependencyTarget = dependencyTargets[index];
-        if (typeof nativeTargets[dependencyTarget] == "undefined")
-            throw new Error("Invalid target: " + dependencyTarget);
-        }
-
     var pbxTargetDependency = 'PBXTargetDependency',
         pbxContainerItemProxy = 'PBXContainerItemProxy',
         pbxTargetDependencySection = this.hash.project.objects[pbxTargetDependency],
@@ -836,15 +827,15 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
 
     for (var index = 0; index < dependencyTargets.length; index++) {
         var dependencyTargetUuid = dependencyTargets[index],
-            dependencyTargetCommentKey = f("%s_comment", dependencyTargetUuid),
+            dependencyTargetCommentKey = f("", dependencyTargetUuid),
             targetDependencyUuid = this.generateUuid(),
             targetDependencyCommentKey = f("%s_comment", targetDependencyUuid),
             itemProxyUuid = this.generateUuid(),
-            itemProxyCommentKey = f("%s_comment", itemProxyUuid),
+            itemProxyCommentKey = f("", itemProxyUuid),
             itemProxy = {
                 isa: pbxContainerItemProxy,
                 containerPortal: this.hash.project['rootObject'],
-                containerPortal_comment: this.hash.project['rootObject_comment'],
+                containerPortal_comment: this.hash.project[''],
                 proxyType: 1,
                 remoteGlobalIDString: dependencyTargetUuid,
                 remoteInfo: nativeTargets[dependencyTargetUuid].name
@@ -857,7 +848,7 @@ pbxProject.prototype.addTargetDependency = function(target, dependencyTargets) {
                 targetProxy_comment: pbxContainerItemProxy
             };
 
-        if (pbxContainerItemProxySection && pbxTargetDependencySection) {
+        {
             pbxContainerItemProxySection[itemProxyUuid] = itemProxy;
             pbxContainerItemProxySection[itemProxyCommentKey] = pbxContainerItemProxy;
             pbxTargetDependencySection[targetDependencyUuid] = targetDependency;

I discovered this while looking at the mutation testing results of PR #56 (watch2 support).

I think we should try to add the missing test coverage soon since this function is used to support the new watch2 functionality. However, I do not think this should block merge of PR #56.

This is also related to #73 (internal pbxProject.prototype.addTargetDependency call not properly tested).

/cc @l3ender

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions