コード例 #1
0
  @Test
  public void testActionTemplateExpansionFunction() throws Exception {
    Artifact inputTreeArtifact =
        createAndPopulateTreeArtifact("inputTreeArtifact", "child0", "child1", "child2");
    Artifact outputTreeArtifact = createTreeArtifact("outputTreeArtifact");

    SpawnActionTemplate spawnActionTemplate =
        ActionsTestUtil.createDummySpawnActionTemplate(inputTreeArtifact, outputTreeArtifact);
    List<Action> actions = evaluate(spawnActionTemplate);
    assertThat(actions).hasSize(3);

    ArtifactOwner owner =
        ActionTemplateExpansionValue.createActionTemplateExpansionKey(spawnActionTemplate);
    int i = 0;
    for (Action action : actions) {
      String childName = "child" + i;
      assertThat(Artifact.toExecPaths(action.getInputs()))
          .contains("out/inputTreeArtifact/" + childName);
      assertThat(Artifact.toExecPaths(action.getOutputs()))
          .containsExactly("out/outputTreeArtifact/" + childName);
      assertThat(Iterables.getOnlyElement(action.getOutputs()).getArtifactOwner()).isEqualTo(owner);
      ++i;
    }
  }
コード例 #2
0
ファイル: SkyframeBuildView.java プロジェクト: runt18/bazel
 private void setDeserializedArtifactOwners() throws ViewCreationFailedException {
   Map<PathFragment, Artifact> deserializedArtifactMap =
       artifactFactory.getDeserializedArtifacts();
   Set<Artifact> deserializedArtifacts = new HashSet<>();
   for (Artifact artifact : deserializedArtifactMap.values()) {
     if (!artifact.getExecPath().getBaseName().endsWith(".gcda")) {
       // gcda files are classified as generated artifacts, but are not actually generated. All
       // others need owners.
       deserializedArtifacts.add(artifact);
     }
   }
   if (deserializedArtifacts.isEmpty()) {
     // If there are no deserialized artifacts to process, don't pay the price of iterating over
     // the graph.
     return;
   }
   for (Map.Entry<SkyKey, ActionLookupValue> entry :
       skyframeExecutor.getActionLookupValueMap().entrySet()) {
     for (Action action : entry.getValue().getActionsForFindingArtifactOwners()) {
       for (Artifact output : action.getOutputs()) {
         Artifact deserializedArtifact = deserializedArtifactMap.get(output.getExecPath());
         if (deserializedArtifact != null) {
           deserializedArtifact.setArtifactOwner((ActionLookupKey) entry.getKey().argument());
           deserializedArtifacts.remove(deserializedArtifact);
         }
       }
     }
   }
   if (!deserializedArtifacts.isEmpty()) {
     throw new ViewCreationFailedException(
         "These artifacts were read in from the FDO profile but"
             + " have no generating action that could be found. If you are confident that your profile was"
             + " collected from the same source state at which you're building, please report this:\n"
             + Artifact.asExecPaths(deserializedArtifacts));
   }
   artifactFactory.clearDeserializedArtifacts();
 }