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"