diff --git a/src/test/shell/bazel/bazel_symlink_test.sh b/src/test/shell/bazel/bazel_symlink_test.sh index 52bb8b744cefaf..62758d9036c7ec 100755 --- a/src/test/shell/bazel/bazel_symlink_test.sh +++ b/src/test/shell/bazel/bazel_symlink_test.sh @@ -228,17 +228,6 @@ EOF function test_file_instead_of_symlink() { mkdir -p a - cat > a/MakeSymlink.java <<'EOF' -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -public class MakeSymlink { - public static void main(String[] args) throws IOException { - Files.createSymbolicLink(Paths.get(args[0]), Paths.get(args[1])); - } -} -EOF - cat > a/a.bzl <<'EOF' def _bad_symlink_impl(ctx): symlink = ctx.actions.declare_symlink(ctx.label.name) @@ -266,12 +255,6 @@ EOF cat > a/BUILD <<'EOF' load(":a.bzl", "bad_symlink", "bad_write") -java_binary( - name = "MakeSymlink", - srcs = ["MakeSymlink.java"], - main_class = "MakeSymlink", -) - bad_symlink(name="bs", link_target="bad/symlink") genrule(name="bsg", srcs=[":bs"], outs=["bsgo"], cmd="echo BSGO > $@") @@ -282,8 +265,9 @@ genrule( name="bg", srcs=[], outs=["bgo"], - exec_tools = [":MakeSymlink"], - cmd = "$(execpath :MakeSymlink) $@ bad/symlink", + # We use python rather than a simple ln since the latter doesn't handle dangling symlinks on + # Windows. + cmd = "python3 -c 'import os, sys; os.symlink(*sys.argv[1:])' bad/symlink $@", ) EOF @@ -344,11 +328,15 @@ EOF def _a_impl(ctx): symlink = ctx.actions.declare_symlink(ctx.label.name + ".link") output = ctx.actions.declare_file(ctx.label.name + ".file") - ctx.actions.run( + ctx.actions.run_shell( outputs = [symlink], - executable = ctx.executable._make_symlink, - arguments = [symlink.path, ctx.attr.link_target], inputs = depset([]), + # We use python rather than a simple ln since the latter doesn't handle dangling symlinks + # on Windows. + command = "python3 -c 'import os, sys; os.symlink(*sys.argv[1:])' {target} {name}".format( + target = ctx.attr.link_target, + name = symlink.path, + ), ) ctx.actions.run_shell( outputs = [output], @@ -361,11 +349,6 @@ a = rule( implementation = _a_impl, attrs = { "link_target": attr.string(), - "_make_symlink": attr.label( - default = ":MakeSymlink", - executable = True, - cfg = "exec", - ) } ) EOF @@ -373,11 +356,6 @@ EOF cat > a/BUILD <<'EOF' load(":a.bzl", "a") -java_binary( - name = "MakeSymlink", - srcs = ["MakeSymlink.java"], - main_class = "MakeSymlink", -) a(name="a", link_target="somewhere/over/the/rainbow") EOF