2022-04-01 03:04:35 +00:00
|
|
|
"tests for run_binary"
|
|
|
|
|
|
|
|
load("@bazel_skylib//rules:write_file.bzl", "write_file")
|
|
|
|
load("//lib:run_binary.bzl", "run_binary")
|
|
|
|
load("//lib:diff_test.bzl", "diff_test")
|
|
|
|
load("//lib:copy_to_directory.bzl", "copy_to_directory")
|
|
|
|
|
|
|
|
write_file(
|
|
|
|
name = "make_dir_a_sh",
|
|
|
|
out = "make_dir_a.sh",
|
|
|
|
content = [
|
|
|
|
"#!/usr/bin/env bash",
|
|
|
|
"set -o errexit -o nounset -o pipefail",
|
2022-06-16 23:58:41 +00:00
|
|
|
"sleep 3",
|
2022-04-01 03:04:35 +00:00
|
|
|
"outdir=$1",
|
|
|
|
"echo 'foo' > \"$outdir/foo\"",
|
|
|
|
"echo 'bar' > \"$outdir/bar\"",
|
|
|
|
],
|
|
|
|
is_executable = True,
|
|
|
|
)
|
|
|
|
|
|
|
|
sh_binary(
|
|
|
|
name = "make_dir_a",
|
|
|
|
srcs = [":make_dir_a.sh"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# target-under-test
|
|
|
|
run_binary(
|
|
|
|
name = "dir_a",
|
|
|
|
args = ["$(@D)"],
|
2022-06-16 23:58:41 +00:00
|
|
|
execution_requirements = {
|
|
|
|
"no-cache": "1",
|
|
|
|
},
|
|
|
|
mnemonic = "SomeAction",
|
2022-06-16 23:26:29 +00:00
|
|
|
out_dirs = ["dir_a"],
|
2022-06-16 23:58:41 +00:00
|
|
|
progress_message = "doing some work to make %{output}",
|
2022-04-01 03:04:35 +00:00
|
|
|
tool = ":make_dir_a",
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
|
|
|
name = "make_foo",
|
|
|
|
outs = ["foo"],
|
|
|
|
cmd = "echo 'foo' > $@",
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
|
|
|
name = "make_bar",
|
|
|
|
outs = ["bar"],
|
|
|
|
cmd = "echo 'bar' > $@",
|
|
|
|
)
|
|
|
|
|
|
|
|
copy_to_directory(
|
|
|
|
name = "dir_b",
|
|
|
|
srcs = [
|
|
|
|
":make_bar",
|
|
|
|
":make_foo",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
diff_test(
|
|
|
|
name = "dir_test",
|
|
|
|
file1 = ":dir_a",
|
|
|
|
file2 = ":dir_b",
|
|
|
|
)
|