diff options
author | buchgr <buchgr@google.com> | 2018-08-02 06:47:19 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-08-02 06:48:54 -0700 |
commit | d4d3d506f4cf6cfaafaeeb717d681ff7784e2384 (patch) | |
tree | 0dd0aad48aadde21b44d6153b3489bcd882ba904 /src/test/shell | |
parent | dcd7c63d09e12fc3e2a9ca80b1422e4bcdd2740f (diff) |
remote: add support for directory inputs in runfiles
Add support for tree artifacts (ctx.action.declare_directory(...)) in
runfiles. Before this change we would throw away the information
about the files inside a tree artifact before executing an action.
That's fine for local execution where the sandbox just copies/symlinks
a directory and doesn't care much what's inside. However, in remote
execution we actually need to upload each individual file and so
we need to be aware of all individual files not just directories.
This change makes it so that this information is made available to a
SpawnRunner via the SpawnInputExpander.
RELNOTES: None
PiperOrigin-RevId: 207091668
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/bazel/remote/remote_execution_test.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/test/shell/bazel/remote/remote_execution_test.sh b/src/test/shell/bazel/remote/remote_execution_test.sh index 9b2ac86c65..73097ab43d 100755 --- a/src/test/shell/bazel/remote/remote_execution_test.sh +++ b/src/test/shell/bazel/remote/remote_execution_test.sh @@ -576,6 +576,77 @@ EOF expect_log "/l is a symbolic link" } +function test_treeartifact_in_runfiles() { + mkdir -p a + cat > a/BUILD <<'EOF' +load(":output_directory.bzl", "gen_output_dir", "gen_output_dir_test") + +gen_output_dir( + name = "skylark_output_dir", + outdir = "dir", +) + +gen_output_dir_test( + name = "skylark_output_dir_test", + dir = ":skylark_output_dir", +) +EOF + cat > a/output_directory.bzl <<'EOF' +def _gen_output_dir_impl(ctx): + output_dir = ctx.actions.declare_directory(ctx.attr.outdir) + ctx.actions.run_shell( + outputs = [output_dir], + inputs = [], + command = """ + mkdir -p $1/sub; \ + echo "foo" > $1/foo; \ + echo "bar" > $1/sub/bar + """, + arguments = [output_dir.path], + ) + return [ + DefaultInfo(files=depset(direct=[output_dir]), + runfiles = ctx.runfiles(files = [output_dir])) + ] +gen_output_dir = rule( + implementation = _gen_output_dir_impl, + attrs = { + "outdir": attr.string(mandatory = True), + }, +) +def _gen_output_dir_test_impl(ctx): + test = ctx.actions.declare_file(ctx.label.name) + ctx.actions.write(test, "echo hello world") + myrunfiles = ctx.runfiles(files=ctx.attr.dir.default_runfiles.files.to_list()) + return [ + DefaultInfo( + executable = test, + runfiles = myrunfiles, + ), + ] +gen_output_dir_test = rule( + implementation = _gen_output_dir_test_impl, + test = True, + attrs = { + "dir": attr.label(mandatory = True), + }, +) +EOF + # Also test this directory inputs with sandboxing. Ideally we would add such + # a test into the sandboxing module. + bazel test \ + --spawn_strategy=sandboxed \ + //a:skylark_output_dir_test \ + || fail "Failed to run //a:skylark_output_dir_test with sandboxing" + + bazel test \ + --spawn_strategy=remote \ + --remote_executor=localhost:${worker_port} \ + //a:skylark_output_dir_test \ + || fail "Failed to run //a:skylark_output_dir_test with remote execution" +} + + # TODO(alpha): Add a test that fails remote execution when remote worker # supports sandbox. |