Skip to content

Commit 73b2d39

Browse files
committed
Download directory output for test actions
1 parent 601f909 commit 73b2d39

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/main/java/com/google/devtools/build/lib/remote/ToplevelArtifactsDownloader.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@
4747
import com.google.devtools.build.lib.skyframe.TreeArtifactValue;
4848
import com.google.devtools.build.lib.util.Pair;
4949
import com.google.devtools.build.lib.vfs.Path;
50+
import com.google.devtools.build.lib.vfs.Symlinks;
5051
import com.google.devtools.build.skyframe.MemoizingEvaluator;
5152
import com.google.devtools.build.skyframe.SkyValue;
53+
import java.io.IOException;
5254
import java.util.HashMap;
5355
import javax.annotation.Nullable;
5456

@@ -117,6 +119,18 @@ public interface PathToMetadataConverter {
117119
}
118120

119121
private void downloadTestOutput(Path path) {
122+
if (path.isDirectory()) {
123+
try {
124+
var entries = path.readdir(Symlinks.FOLLOW);
125+
for (var entry : entries) {
126+
downloadTestOutput(path.getRelative(entry.getName()));
127+
return;
128+
}
129+
} catch (IOException e) {
130+
logger.atWarning().withCause(e).log("Failed to read dir %s.", path);
131+
}
132+
}
133+
120134
// Since the event is fired within action execution, the skyframe doesn't know the outputs of
121135
// test actions yet, so we can't get their metadata through skyframe. However, the fileSystem
122136
// of the path is an ActionFileSystem, we use it to get the metadata for this file.

src/test/shell/bazel/remote/build_without_the_bytes_test.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,31 @@ EOF
685685
expect_log "test.outputs_manifest__MANIFEST"
686686
}
687687

688+
function test_nozip_undeclared_test_outputs() {
689+
mkdir -p a
690+
cat > a/test.sh << 'EOF'
691+
#!/bin/sh
692+
echo foo > "$TEST_UNDECLARED_OUTPUTS_DIR/text.txt"
693+
EOF
694+
chmod +x a/test.sh
695+
696+
cat > a/BUILD <<'EOF'
697+
sh_test(
698+
name = "foo",
699+
srcs = ["test.sh"],
700+
)
701+
EOF
702+
703+
bazel test \
704+
--remote_executor=grpc://localhost:${worker_port} \
705+
--remote_download_toplevel \
706+
--nozip_undeclared_test_outputs \
707+
//a:foo || fail "Failed to test //a:foo"
708+
709+
[[ -e "bazel-testlogs/a/foo/test.outputs/text.txt" ]] || fail "bazel-testlogs/a/foo/test.outputs/text.txt does not exist"
710+
assert_contains "foo" "bazel-testlogs/a/foo/test.outputs/text.txt"
711+
}
712+
688713
function test_multiple_test_attempts() {
689714
# Test that test logs of multiple test attempts can be renamed and reported by
690715
# BEP.

0 commit comments

Comments
 (0)