Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.3.0] Download directory output for test actions #18846

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
import com.google.devtools.build.lib.skyframe.TreeArtifactValue;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.Symlinks;
import com.google.devtools.build.skyframe.MemoizingEvaluator;
import com.google.devtools.build.skyframe.SkyValue;
import java.io.IOException;
import java.util.HashMap;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -117,6 +119,18 @@ public interface PathToMetadataConverter {
}

private void downloadTestOutput(Path path) {
if (path.isDirectory()) {
try {
var entries = path.readdir(Symlinks.FOLLOW);
for (var entry : entries) {
downloadTestOutput(path.getRelative(entry.getName()));
return;
}
} catch (IOException e) {
logger.atWarning().withCause(e).log("Failed to read dir %s.", path);
}
}

// Since the event is fired within action execution, the skyframe doesn't know the outputs of
// test actions yet, so we can't get their metadata through skyframe. However, the fileSystem
// of the path is an ActionFileSystem, we use it to get the metadata for this file.
Expand Down
25 changes: 25 additions & 0 deletions src/test/shell/bazel/remote/build_without_the_bytes_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,31 @@ EOF
expect_log "test.outputs_manifest__MANIFEST"
}

function test_nozip_undeclared_test_outputs() {
mkdir -p a
cat > a/test.sh << 'EOF'
#!/bin/sh
echo foo > "$TEST_UNDECLARED_OUTPUTS_DIR/text.txt"
EOF
chmod +x a/test.sh

cat > a/BUILD <<'EOF'
sh_test(
name = "foo",
srcs = ["test.sh"],
)
EOF

bazel test \
--remote_executor=grpc://localhost:${worker_port} \
--remote_download_toplevel \
--nozip_undeclared_test_outputs \
//a:foo || fail "Failed to test //a:foo"

[[ -e "bazel-testlogs/a/foo/test.outputs/text.txt" ]] || fail "bazel-testlogs/a/foo/test.outputs/text.txt does not exist"
assert_contains "foo" "bazel-testlogs/a/foo/test.outputs/text.txt"
}

function test_multiple_test_attempts() {
# Test that test logs of multiple test attempts can be renamed and reported by
# BEP.
Expand Down