Skip to content

Commit 1d577ba

Browse files
tjgqcopybara-github
authored andcommitted
Set --windows_enable_runfiles for runfiles_test.sh on Windows.
This test asserts the presence of symlinks in runfiles trees, but it currently works without --windows_enable_runfiles because symlinks are created by an external process, which will unconditionally attempt to create them. Once --experimental_inprocess_symlink_creation is flipped, the --windows_enable_runfiles flag will be respected (i.e., symlinks will be created only if the flag is enabled, otherwise falling back to a copy, as is already the case outside of runfiles). PiperOrigin-RevId: 671342054 Change-Id: I0a5b1b8ea2c83a0c831ea41790cc3f2e458abda1
1 parent 25d0f05 commit 1d577ba

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/test/shell/integration/runfiles_test.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ if "$is_windows"; then
6060
export MSYS_NO_PATHCONV=1
6161
export MSYS2_ARG_CONV_EXCL="*"
6262
export EXT=".exe"
63+
export EXTRA_STARTUP_FLAGS="--windows_enable_symlinks"
6364
export EXTRA_BUILD_FLAGS="--incompatible_use_python_toolchains=false \
6465
--enable_runfiles --build_python_zip=0"
6566
else
6667
export EXT=""
68+
export EXTRA_STARTUP_FLAGS=""
6769
export EXTRA_BUILD_FLAGS="--incompatible_use_python_toolchains=false"
6870
fi
6971

@@ -140,7 +142,7 @@ genrule(name = "hidden",
140142
outs = [ "e/f/g/hidden.txt" ],
141143
cmd = "touch \$@")
142144
EOF
143-
bazel build $pkg:bin $EXTRA_BUILD_FLAGS >&$TEST_log 2>&1 || fail "build failed"
145+
bazel $EXTRA_STARTUP_FLAGS build $pkg:bin $EXTRA_BUILD_FLAGS >&$TEST_log 2>&1 || fail "build failed"
144146

145147
# we get a warning that hidden.txt is inaccessible
146148
expect_log_once "${pkg}/e/f/g/hidden.txt obscured by ${pkg}/e/f "
@@ -174,7 +176,7 @@ py_binary(name = "py",
174176
data = ["e/f/g/ignored.txt"],
175177
deps = ["//:root"])
176178
EOF
177-
bazel build $pkg:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "build failed"
179+
bazel $EXTRA_STARTUP_FLAGS build $pkg:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "build failed"
178180
workspace_root=$PWD
179181

180182
cd ${PRODUCT_NAME}-bin/$pkg/foo${EXT}.runfiles
@@ -284,7 +286,7 @@ sh_binary(name = "foo",
284286
srcs = [ "x/y/z.sh" ],
285287
data = [ "e/f" ])
286288
EOF
287-
bazel build $pkg:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "build failed"
289+
bazel $EXTRA_STARTUP_FLAGS build $pkg:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "build failed"
288290

289291
cd ${PRODUCT_NAME}-bin/$pkg/foo${EXT}.runfiles
290292

@@ -391,12 +393,12 @@ EOF
391393
cat > thing.cc <<EOF
392394
int main() { return 0; }
393395
EOF
394-
bazel build --noenable_bzlmod --enable_workspace //:thing $EXTRA_BUILD_FLAGS &> $TEST_log || fail "Build failed"
396+
bazel $EXTRA_STARTUP_FLAGS build --noenable_bzlmod --enable_workspace //:thing $EXTRA_BUILD_FLAGS &> $TEST_log || fail "Build failed"
395397
[[ -d ${PRODUCT_NAME}-bin/thing${EXT}.runfiles/foo ]] || fail "foo not found"
396398

397399
# Change workspace name to bar.
398400
sed -ie 's,workspace(.*,workspace(name = "bar"),' WORKSPACE
399-
bazel build --noenable_bzlmod --enable_workspace //:thing $EXTRA_BUILD_FLAGS &> $TEST_log || fail "Build failed"
401+
bazel $EXTRA_STARTUP_FLAGS build --noenable_bzlmod --enable_workspace //:thing $EXTRA_BUILD_FLAGS &> $TEST_log || fail "Build failed"
400402
[[ -d ${PRODUCT_NAME}-bin/thing${EXT}.runfiles/bar ]] || fail "bar not found"
401403
[[ ! -d ${PRODUCT_NAME}-bin/thing${EXT}.runfiles/foo ]] \
402404
|| fail "Old foo still found"
@@ -490,7 +492,7 @@ EOF
490492
chmod +x foo.sh
491493

492494
# Build once to create a runfiles directory.
493-
bazel build //:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "build failed"
495+
bazel $EXTRA_STARTUP_FLAGS build //:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "build failed"
494496

495497
# Remove the MANIFEST file that was created by the previous build.
496498
# Create an inaccessible file in the place where build-runfiles writes
@@ -505,7 +507,7 @@ EOF
505507

506508
# Even with the inaccessible temporary file in place, build-runfiles
507509
# should complete successfully. The MANIFEST file should be recreated.
508-
bazel build //:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "build failed"
510+
bazel $EXTRA_STARTUP_FLAGS build //:foo $EXTRA_BUILD_FLAGS >&$TEST_log || fail "build failed"
509511
[[ -f ${PRODUCT_NAME}-bin/foo${EXT}.runfiles/MANIFEST ]] \
510512
|| fail "MANIFEST file not recreated"
511513
}

0 commit comments

Comments
 (0)