From d4842e17e2bc5b12185356e44e30c699a9326ceb Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Mon, 19 Aug 2024 13:36:33 +0200 Subject: [PATCH] Add test --- src/test/shell/integration/runfiles_test.sh | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/test/shell/integration/runfiles_test.sh b/src/test/shell/integration/runfiles_test.sh index 5526f1364923da..061822b835ecf2 100755 --- a/src/test/shell/integration/runfiles_test.sh +++ b/src/test/shell/integration/runfiles_test.sh @@ -569,4 +569,37 @@ EOF assert_contains '/link_two$' *-bin/a/go } +function test_spaces_in_runfiles_paths() { + mkdir -p pkg + cat > pkg/defs.bzl <<'EOF' +def _spaces_impl(ctx): + out = ctx.actions.declare_file(" a b .txt") + ctx.actions.write(out, "my content") + return [DefaultInfo(files = depset([out]))] + +spaces = rule( + implementation = _spaces_impl, +) +EOF + cat > pkg/BUILD <<'EOF' +load(":defs.bzl", "spaces") +spaces(name = "spaces") +sh_test( + name = "foo", + srcs = ["foo.sh"], + data = [":spaces"], +) +EOF + cat > pkg/foo.sh <<'EOF' +#!/bin/bash +if [[ "$(cat "pkg/ a b .txt")" != "my content" ]]; then + echo "unexpected content or not found" + exit 1 +fi +EOF + chmod +x pkg/foo.sh + + bazel test //pkg:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "test failed" +} + run_suite "runfiles"