Clarify documentation followup for unknown commit PiperOrigin-RevId: 222219274
diff --git a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildToolLogs.java b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildToolLogs.java index fe27a99..82a16c4 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildToolLogs.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventstream/BuildToolLogs.java
@@ -22,8 +22,16 @@ /** Event reporting on statistics about the build. */ public class BuildToolLogs implements BuildEventWithOrderConstraint { + /** These values are posted as byte strings to the BEP. */ private final Collection<Pair<String, ByteString>> directValues; + /** + * These values are posted as URIs to the BEP; if these reference files, those are not uploaded. + */ private final Collection<Pair<String, String>> directUris; + /** + * These values are local files that are uploaded if required, and turned into URIs as part of the + * process. + */ private final Collection<Pair<String, Path>> logFiles; public BuildToolLogs(
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildResult.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildResult.java index 20cf11f..a77e05b 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildResult.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildResult.java
@@ -274,7 +274,9 @@ .toString(); } - /** Collection of data for the build tool logs event. */ + /** + * Collection of data for the build tool logs event. See {@link BuildToolLogs} for details. + */ public static final class BuildToolLogCollection { private final List<Pair<String, ByteString>> directValues = new ArrayList<>(); private final List<Pair<String, String>> directUris = new ArrayList<>();
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java index 844cbca..4713540 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildTool.java
@@ -360,6 +360,9 @@ new BuildCompleteEvent( result, ImmutableList.of(BuildEventId.buildToolLogs(), BuildEventId.buildMetrics()))); + // Post the build tool logs event; the corresponding local files may be contributed from + // modules, and this has to happen after posting the BuildCompleteEvent because that's when + // modules add their data to the collection. env.getEventBus().post(result.getBuildToolLogCollection().freeze().toEvent()); if (ie != null) { if (exitCondition.equals(ExitCode.SUCCESS)) {
diff --git a/src/test/java/com/google/devtools/build/lib/buildeventstream/BUILD b/src/test/java/com/google/devtools/build/lib/buildeventstream/BUILD index 6a74954..bf89bf5 100644 --- a/src/test/java/com/google/devtools/build/lib/buildeventstream/BUILD +++ b/src/test/java/com/google/devtools/build/lib/buildeventstream/BUILD
@@ -18,6 +18,7 @@ deps = [ "//src/main/java/com/google/devtools/build/lib:runtime", "//src/main/java/com/google/devtools/build/lib/buildeventstream", + "//src/main/java/com/google/devtools/build/lib/buildeventstream/proto:build_event_stream_java_proto", "//src/main/java/com/google/devtools/build/lib/vfs", "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs", "//src/main/java/com/google/devtools/common/options",
diff --git a/src/test/java/com/google/devtools/build/lib/buildeventstream/LastBuildEventTest.java b/src/test/java/com/google/devtools/build/lib/buildeventstream/LastBuildEventTest.java new file mode 100644 index 0000000..419cb29 --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/buildeventstream/LastBuildEventTest.java
@@ -0,0 +1,56 @@ +// Copyright 2018 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.buildeventstream; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.buildeventstream.BuildEvent.LocalFile; +import com.google.devtools.build.lib.buildeventstream.BuildEvent.LocalFile.LocalFileType; +import java.util.Collection; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link LastBuildEvent}. */ +@RunWith(JUnit4.class) +public class LastBuildEventTest { + + @Test + public void testForwardsReferencedLocalFilesCall() { + LocalFile localFile = new LocalFile(null, LocalFileType.FAILED_TEST_OUTPUT); + LastBuildEvent event = new LastBuildEvent(new BuildEvent() { + @Override + public BuildEventId getEventId() { + return null; + } + + @Override + public Collection<BuildEventId> getChildrenEvents() { + return null; + } + + @Override + public Collection<LocalFile> referencedLocalFiles() { + return ImmutableList.of(localFile); + } + + @Override + public BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventContext context) { + return null; + } + }); + assertThat(event.referencedLocalFiles()).containsExactly(localFile); + } +}