Removing line ending matches in tests to be compatible on Windows
grep was upgraded to 3.5 after updating MSYS on Winodws VM, which no longer matches CRLF line endings with `$`.
Fixes https://github.com/bazelbuild/bazel/issues/13816
RELNOTES: None
PiperOrigin-RevId: 389600750
diff --git a/.bazelci/postsubmit.yml b/.bazelci/postsubmit.yml
index 93a1b37..c7c804b 100644
--- a/.bazelci/postsubmit.yml
+++ b/.bazelci/postsubmit.yml
@@ -269,11 +269,6 @@
- "//tools/jdk/..."
- "//tools/python/..."
- "//tools/test/..."
- # These tests fail with our new Windows image:
- # https://github.com/bazelbuild/bazel/issues/13816
- - "-//src/test/shell/bazel:resource_compiler_toolchain_test"
- - "-//src/test/shell/integration:loading_phase_tests"
- - "-//src/test/shell/integration:target_compatible_with_test"
# Re-enable the following tests on Windows:
# https://github.com/bazelbuild/bazel/issues/4292
- "-//src/test/java/com/google/devtools/build/android/desugar/nest/..."
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
index 376da19..004f1ad 100644
--- a/.bazelci/presubmit.yml
+++ b/.bazelci/presubmit.yml
@@ -260,11 +260,6 @@
- "//tools/jdk/..."
- "//tools/python/..."
- "//tools/test/..."
- # These tests fail with our new Windows image:
- # https://github.com/bazelbuild/bazel/issues/13816
- - "-//src/test/shell/bazel:resource_compiler_toolchain_test"
- - "-//src/test/shell/integration:loading_phase_tests"
- - "-//src/test/shell/integration:target_compatible_with_test"
# Re-enable the following tests on Windows:
# https://github.com/bazelbuild/bazel/issues/4292
- "-//src/test/java/com/google/devtools/build/android/desugar/nest/..."
diff --git a/src/test/shell/bazel/resource_compiler_toolchain_test.sh b/src/test/shell/bazel/resource_compiler_toolchain_test.sh
index 34e733e..aeab86e 100755
--- a/src/test/shell/bazel/resource_compiler_toolchain_test.sh
+++ b/src/test/shell/bazel/resource_compiler_toolchain_test.sh
@@ -181,14 +181,14 @@
[[ -e bazel-bin/foo.res ]] || fail "missing output"
grep -q "src=foo.rc" "bazel-bin/foo.res" || fail "bad output"
grep -q "out=.*\bfoo.res" "bazel-bin/foo.res" || fail "bad output"
- grep -q ".*\bres1.dat$" "bazel-bin/foo.res" || fail "bad output"
- grep -q ".*\bres2.dat$" "bazel-bin/foo.res" || fail "bad output"
+ grep -q ".*\bres1.dat" "bazel-bin/foo.res" || fail "bad output"
+ grep -q ".*\bres2.dat" "bazel-bin/foo.res" || fail "bad output"
[[ -e bazel-bin/bar.res ]] || fail "missing output"
grep -q "src=bar.rc" "bazel-bin/bar.res" || fail "bad output"
grep -q "out=.*\bbar.res" "bazel-bin/bar.res" || fail "bad output"
- grep -q ".*\bres1.dat$" "bazel-bin/bar.res" || fail "bad output"
- grep -q ".*\bres2.dat$" "bazel-bin/bar.res" || fail "bad output"
+ grep -q ".*\bres1.dat" "bazel-bin/bar.res" || fail "bad output"
+ grep -q ".*\bres2.dat" "bazel-bin/bar.res" || fail "bad output"
}
function _assert_no_outputs() {
diff --git a/src/test/shell/integration/loading_phase_test.sh b/src/test/shell/integration/loading_phase_test.sh
index 5d2609f..d4f8376 100755
--- a/src/test/shell/integration/loading_phase_test.sh
+++ b/src/test/shell/integration/loading_phase_test.sh
@@ -598,8 +598,8 @@
cd "$pkg/subdir"
bazel query '../BUILD + ../foo' >output 2> "$TEST_log" \
|| fail "Expected success"
- assert_contains "^//$pkg:BUILD\$" output
- assert_contains "^//$pkg:foo\$" output
+ assert_contains "^//$pkg:BUILD" output
+ assert_contains "^//$pkg:foo" output
}
function test_target_with_BUILD() {
@@ -607,7 +607,7 @@
mkdir -p "$pkg" || fail "could not create \"$pkg\""
echo 'filegroup(name = "foo/BUILD", srcs = [])' > "$pkg/BUILD" || fail "echo"
bazel query "$pkg/foo/BUILD" >output 2> "$TEST_log" || fail "Expected success"
- assert_contains "^//$pkg:foo/BUILD\$" output
+ assert_contains "^//$pkg:foo/BUILD" output
}
function test_directory_with_BUILD() {
@@ -615,7 +615,7 @@
mkdir -p "$pkg/BUILD" || fail "could not create \"$pkg/BUILD\""
touch "$pkg/BUILD/BUILD" || fail "Couldn't touch"
bazel query "$pkg/BUILD" >output 2> "$TEST_log" || fail "Expected success"
- assert_contains "^//$pkg/BUILD:BUILD\$" output
+ assert_contains "^//$pkg/BUILD:BUILD" output
}
function test_missing_BUILD() {
diff --git a/src/test/shell/integration/target_compatible_with_test.sh b/src/test/shell/integration/target_compatible_with_test.sh
index 1d9feef..8121e76 100755
--- a/src/test/shell/integration/target_compatible_with_test.sh
+++ b/src/test/shell/integration/target_compatible_with_test.sh
@@ -637,7 +637,7 @@
# Validate that we get the dependency chain printed out.
expect_log '^Dependency chain:$'
expect_log '^ //target_skipping:generate_with_tool$'
- expect_log "^ //target_skipping:generator_tool <-- target platform didn't satisfy constraint //target_skipping:foo1$"
+ expect_log "^ //target_skipping:generator_tool <-- target platform didn't satisfy constraint //target_skipping:foo1"
expect_log 'FAILED: Build did NOT complete successfully'
# Validate the test.
@@ -652,7 +652,7 @@
expect_log '^Dependency chain:$'
expect_log '^ //target_skipping:generated_test$'
expect_log '^ //target_skipping:generate_with_tool$'
- expect_log "^ //target_skipping:generator_tool <-- target platform didn't satisfy constraint //target_skipping:foo1$"
+ expect_log "^ //target_skipping:generator_tool <-- target platform didn't satisfy constraint //target_skipping:foo1"
expect_log 'FAILED: Build did NOT complete successfully'
}
@@ -700,7 +700,7 @@
expect_log '^Dependency chain:$'
expect_log '^ //target_skipping:generated_test$'
expect_log '^ //target_skipping:generate_with_tool$'
- expect_log "^ //target_skipping:generator_tool <-- target platform didn't satisfy constraints \[//target_skipping:foo1, //target_skipping:bar2\]$"
+ expect_log "^ //target_skipping:generator_tool <-- target platform didn't satisfy constraints \[//target_skipping:foo1, //target_skipping:bar2\]"
expect_log 'FAILED: Build did NOT complete successfully'
}
@@ -856,7 +856,7 @@
# Make sure that the contents of the file are what we expect.
cp ../${PRODUCT_NAME}-bin/target_skipping/host_tool_message.txt "${TEST_log}"
- expect_log '^Hello World$'
+ expect_log 'Hello World'
}
# Validates that we successfully skip analysistest rule targets when they
@@ -924,8 +924,8 @@
bazel query \
'deps(//target_skipping:sh_foo1)' &> "${TEST_log}" \
|| fail "Bazel query failed unexpectedly."
- expect_log '^//target_skipping:sh_foo1$'
- expect_log '^//target_skipping:genrule_foo1$'
+ expect_log '^//target_skipping:sh_foo1'
+ expect_log '^//target_skipping:genrule_foo1'
}
# Regression test for http://b/189071321: --notool_deps should exclude constraints.
@@ -937,6 +937,11 @@
--notool_deps \
'deps(//target_skipping:sh_foo1)' &> "${TEST_log}" \
|| fail "Bazel query failed unexpectedly."
+
+ if "$is_windows"; then
+ sed -i 's/\r//g' "${TEST_log}"
+ fi
+
expect_log '^//target_skipping:sh_foo1$'
expect_log '^//target_skipping:genrule_foo1$'
expect_not_log '^//target_skipping:foo1$'