From 00310a5b91868e6a8feaa04bc481b7442ccb9226 Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Wed, 5 Jun 2024 13:48:07 -0700 Subject: [PATCH] test: add test / example of using root path on a run_binary directory output (#862) --- lib/tests/run_binary/BUILD.bazel | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/tests/run_binary/BUILD.bazel b/lib/tests/run_binary/BUILD.bazel index 2cd6fbd..393c689 100644 --- a/lib/tests/run_binary/BUILD.bazel +++ b/lib/tests/run_binary/BUILD.bazel @@ -4,6 +4,7 @@ load("@bazel_skylib//rules:write_file.bzl", "write_file") load("//lib:copy_to_directory.bzl", "copy_to_directory") load("//lib:diff_test.bzl", "diff_test") load("//lib:run_binary.bzl", "run_binary") +load("//lib:testing.bzl", "assert_contains") write_file( name = "make_dir_a_sh", @@ -32,7 +33,7 @@ run_binary( "no-cache": "1", }, mnemonic = "SomeAction", - out_dirs = ["dir_a"], + out_dirs = ["dir_a_out"], progress_message = "doing some work to make %{output}", tool = ":make_dir_a", ) @@ -62,3 +63,17 @@ diff_test( file1 = ":dir_a", file2 = ":dir_b", ) + +# test that rootpath can be used on the out_dir of a run_binary +genrule( + name = "dir_a_rootpath", + srcs = [":dir_a"], + outs = ["dir_a_rootpath"], + cmd = "echo $(rootpath :dir_a) > $@", +) + +assert_contains( + name = "dir_a_rootpath_test", + actual = ":dir_a_rootpath", + expected = "lib/tests/run_binary/dir_a_out", +)