|
966 | 966 | || fail "Failed to run //a:starlark_output_dir_test with remote execution"
|
967 | 967 | }
|
968 | 968 |
|
| 969 | +function generate_empty_treeartifact_build() { |
| 970 | + mkdir -p a |
| 971 | + cat > a/BUILD <<'EOF' |
| 972 | +load(":output_dir.bzl", "gen_output_dir") |
| 973 | +gen_output_dir( |
| 974 | + name = "output-dir", |
| 975 | + outdir = "dir", |
| 976 | +) |
| 977 | +EOF |
| 978 | + cat > a/output_dir.bzl <<'EOF' |
| 979 | +def _gen_output_dir_impl(ctx): |
| 980 | + output_dir = ctx.actions.declare_directory(ctx.attr.outdir) |
| 981 | + ctx.actions.run_shell( |
| 982 | + outputs = [output_dir], |
| 983 | + inputs = [], |
| 984 | + command = "", |
| 985 | + arguments = [output_dir.path], |
| 986 | + ) |
| 987 | + return [ |
| 988 | + DefaultInfo(files = depset(direct = [output_dir])), |
| 989 | + ] |
| 990 | +
|
| 991 | +gen_output_dir = rule( |
| 992 | + implementation = _gen_output_dir_impl, |
| 993 | + attrs = { |
| 994 | + "outdir": attr.string(mandatory = True), |
| 995 | + }, |
| 996 | +) |
| 997 | +EOF |
| 998 | +} |
| 999 | + |
| 1000 | +function test_empty_treeartifact_works_with_remote_execution() { |
| 1001 | + # Test that empty tree artifact works with remote execution |
| 1002 | + generate_empty_treeartifact_build |
| 1003 | + |
| 1004 | + bazel build \ |
| 1005 | + --remote_executor=grpc://localhost:${worker_port} \ |
| 1006 | + //a:output-dir >& $TEST_log || fail "Failed to build" |
| 1007 | +} |
| 1008 | + |
| 1009 | +function test_empty_treeartifact_works_with_remote_cache() { |
| 1010 | + # Test that empty tree artifact works with remote cache |
| 1011 | + generate_empty_treeartifact_build |
| 1012 | + |
| 1013 | + bazel build \ |
| 1014 | + --remote_cache=grpc://localhost:${worker_port} \ |
| 1015 | + //a:output-dir >& $TEST_log || fail "Failed to build" |
| 1016 | + |
| 1017 | + bazel clean |
| 1018 | + |
| 1019 | + bazel build \ |
| 1020 | + --remote_cache=grpc://localhost:${worker_port} \ |
| 1021 | + //a:output-dir >& $TEST_log || fail "Failed to build" |
| 1022 | + |
| 1023 | + expect_log "remote cache hit" |
| 1024 | +} |
| 1025 | + |
969 | 1026 | function test_downloads_minimal() {
|
970 | 1027 | # Test that genrule outputs are not downloaded when using
|
971 | 1028 | # --remote_download_minimal
|
|
0 commit comments