(self, xcode_targets, xcode_target_to_target_dict)
| 386 | self.project._properties["targets"].insert(1, run_all_tests_target) |
| 387 | |
| 388 | def Finalize2(self, xcode_targets, xcode_target_to_target_dict): |
| 389 | # Finalize2 needs to happen in a separate step because the process of |
| 390 | # updating references to other projects depends on the ordering of targets |
| 391 | # within remote project files. Finalize1 is responsible for sorting duty, |
| 392 | # and once all project files are sorted, Finalize2 can come in and update |
| 393 | # these references. |
| 394 | |
| 395 | # To support making a "test runner" target that will run all the tests |
| 396 | # that are direct dependents of any given target, we look for |
| 397 | # xcode_create_dependents_test_runner being set on an Aggregate target, |
| 398 | # and generate a second target that will run the tests runners found under |
| 399 | # the marked target. |
| 400 | for bf_tgt in self.build_file_dict["targets"]: |
| 401 | if int(bf_tgt.get("xcode_create_dependents_test_runner", 0)): |
| 402 | tgt_name = bf_tgt["target_name"] |
| 403 | toolset = bf_tgt["toolset"] |
| 404 | qualified_target = gyp.common.QualifiedTarget( |
| 405 | self.gyp_path, tgt_name, toolset |
| 406 | ) |
| 407 | xcode_target = xcode_targets[qualified_target] |
| 408 | if isinstance(xcode_target, gyp.xcodeproj_file.PBXAggregateTarget): |
| 409 | # Collect all the run test targets. |
| 410 | all_run_tests = [] |
| 411 | pbxtds = xcode_target.GetProperty("dependencies") |
| 412 | for pbxtd in pbxtds: |
| 413 | pbxcip = pbxtd.GetProperty("targetProxy") |
| 414 | dependency_xct = pbxcip.GetProperty("remoteGlobalIDString") |
| 415 | if hasattr(dependency_xct, "test_runner"): |
| 416 | all_run_tests.append(dependency_xct.test_runner) |
| 417 | |
| 418 | # Directly depend on all the runners as they depend on the target |
| 419 | # that builds them. |
| 420 | if len(all_run_tests) > 0: |
| 421 | run_all_target = gyp.xcodeproj_file.PBXAggregateTarget( |
| 422 | { |
| 423 | "name": "Run %s Tests" % tgt_name, |
| 424 | "productName": tgt_name, |
| 425 | }, |
| 426 | parent=self.project, |
| 427 | ) |
| 428 | for run_test_target in all_run_tests: |
| 429 | run_all_target.AddDependency(run_test_target) |
| 430 | |
| 431 | # Insert the test runner after the related target. |
| 432 | idx = self.project._properties["targets"].index(xcode_target) |
| 433 | self.project._properties["targets"].insert( |
| 434 | idx + 1, run_all_target |
| 435 | ) |
| 436 | |
| 437 | # Update all references to other projects, to make sure that the lists of |
| 438 | # remote products are complete. Otherwise, Xcode will fill them in when |
| 439 | # it opens the project file, which will result in unnecessary diffs. |
| 440 | # TODO(mark): This is evil because it relies on internal knowledge of |
| 441 | # PBXProject._other_pbxprojects. |
| 442 | for other_pbxproject in self.project._other_pbxprojects: |
| 443 | self.project.AddOrGetProjectReference(other_pbxproject) |
| 444 | |
| 445 | self.project.SortRemoteProductReferences() |
no test coverage detected