diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/copy_file/BUILD | 56 | ||||
-rwxr-xr-x | tests/copy_file/a_with_exec_bit.txt | 2 | ||||
-rwxr-xr-x | tests/copy_file/copy_file_tests.sh | 22 |
3 files changed, 78 insertions, 2 deletions
diff --git a/tests/copy_file/BUILD b/tests/copy_file/BUILD index 7c8a4c3..79ab7ba 100644 --- a/tests/copy_file/BUILD +++ b/tests/copy_file/BUILD @@ -46,6 +46,7 @@ sh_test( ":file_deps", # Use DefaultInfo.runfiles from 'copy_gen'. ":copy_gen", + ":copy_gen_symlink", "//tests:unittest.bash", ], deps = ["@bazel_tools//tools/bash/runfiles"], @@ -56,6 +57,7 @@ filegroup( # Use DefaultInfo.files from 'copy_src'. srcs = [ ":copy_src", + ":copy_src_symlink", ], ) @@ -64,15 +66,23 @@ filegroup( genrule( name = "run_executables", outs = [ + "xsrc-out-symlink.txt", + "xgen-out-symlink.txt", "xsrc-out.txt", "xgen-out.txt", ], - cmd = ("$(location :bin_src) > $(location xsrc-out.txt) && " + - "$(location :bin_gen) > $(location xgen-out.txt)"), + cmd = " && ".join([ + "$(location :bin_src_symlink) > $(location xsrc-out-symlink.txt)", + "$(location :bin_gen_symlink) > $(location xgen-out-symlink.txt)", + "$(location :bin_src) > $(location xsrc-out.txt)", + "$(location :bin_gen) > $(location xgen-out.txt)", + ]), output_to_bindir = 1, tools = [ ":bin_gen", ":bin_src", + ":bin_gen_symlink", + ":bin_src_symlink", ], ) @@ -82,12 +92,24 @@ sh_binary( srcs = [":copy_xsrc"], ) +# If 'bin_src' is built, then 'copy_xsrc' made its output executable. +sh_binary( + name = "bin_src_symlink", + srcs = [":copy_xsrc_symlink"], +) + # If 'bin_gen' is built, then 'copy_xgen' made its output executable. sh_binary( name = "bin_gen", srcs = [":copy_xgen"], ) +# If 'bin_gen' is built, then 'copy_xgen' made its output executable. +sh_binary( + name = "bin_gen_symlink", + srcs = [":copy_xgen_symlink"], +) + copy_file( name = "copy_src", src = "a.txt", @@ -95,9 +117,23 @@ copy_file( ) copy_file( + name = "copy_src_symlink", + src = "a.txt", + out = "out/a-out-symlink.txt", + allow_symlink = True, +) + +copy_file( name = "copy_gen", src = ":gen", out = "out/gen-out.txt", + allow_symlink = True, +) + +copy_file( + name = "copy_gen_symlink", + src = ":gen", + out = "out/gen-out-symlink.txt", ) copy_file( @@ -108,12 +144,28 @@ copy_file( ) copy_file( + name = "copy_xsrc_symlink", + src = "a_with_exec_bit.txt", + out = "xout/a-out-symlink.sh", + is_executable = True, + allow_symlink = True, +) + +copy_file( name = "copy_xgen", src = ":gen", out = "xout/gen-out.sh", is_executable = True, ) +copy_file( + name = "copy_xgen_symlink", + src = ":gen", + out = "xout/gen-out-symlink.sh", + is_executable = True, + allow_symlink = True, +) + genrule( name = "gen", outs = ["b.txt"], diff --git a/tests/copy_file/a_with_exec_bit.txt b/tests/copy_file/a_with_exec_bit.txt new file mode 100755 index 0000000..acd332a --- /dev/null +++ b/tests/copy_file/a_with_exec_bit.txt @@ -0,0 +1,2 @@ +#!/bin/bash +echo aaa diff --git a/tests/copy_file/copy_file_tests.sh b/tests/copy_file/copy_file_tests.sh index 23f45d5..dfee635 100755 --- a/tests/copy_file/copy_file_tests.sh +++ b/tests/copy_file/copy_file_tests.sh @@ -44,20 +44,42 @@ function test_copy_src() { expect_log '^echo aaa$' } +function test_copy_src_symlink() { + cat "$(rlocation bazel_skylib/tests/copy_file/out/a-out-symlink.txt)" >"$TEST_log" + expect_log '^#!/bin/bash$' + expect_log '^echo aaa$' +} + function test_copy_gen() { cat "$(rlocation bazel_skylib/tests/copy_file/out/gen-out.txt)" >"$TEST_log" expect_log '^#!/bin/bash$' expect_log '^echo potato$' } +function test_copy_gen_symlink() { + cat "$(rlocation bazel_skylib/tests/copy_file/out/gen-out-symlink.txt)" >"$TEST_log" + expect_log '^#!/bin/bash$' + expect_log '^echo potato$' +} + function test_copy_xsrc() { cat "$(rlocation bazel_skylib/tests/copy_file/xsrc-out.txt)" >"$TEST_log" expect_log '^aaa$' } +function test_copy_xsrc_symlink() { + cat "$(rlocation bazel_skylib/tests/copy_file/xsrc-out-symlink.txt)" >"$TEST_log" + expect_log '^aaa$' +} + function test_copy_xgen() { cat "$(rlocation bazel_skylib/tests/copy_file/xgen-out.txt)" >"$TEST_log" expect_log '^potato$' } +function test_copy_xgen_symlink() { + cat "$(rlocation bazel_skylib/tests/copy_file/xgen-out-symlink.txt)" >"$TEST_log" + expect_log '^potato$' +} + run_suite "copy_file_tests test suite" |