aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2017-09-25 10:50:09 -0400
committerGravatar John Cater <jcater@google.com>2017-09-25 12:02:43 -0400
commit66ab13fad654881ed3caccde7c9e0422b222e32e (patch)
tree23da77a6bb54db11ce4ca85936add8876e07d600 /src
parent4af0d7bae584922a4b87d34a901ef7bf049ab90f (diff)
Fix bazel_test_test by removing pollution of config with external bazelrc, such as from /etc/bazel.bazelrc.
Fixes https://github.com/bazelbuild/bazel/issues/3727. This should not be the final fix. There are remaining issues: - This test should pass regardless of the UI used (either fix the experimental UI or fix the test to make fewer assertions). - Outside bazelrcs should not pollute the test. But this fixes the breakage. RELNOTES: N/A PiperOrigin-RevId: 169906770
Diffstat (limited to 'src')
-rwxr-xr-xsrc/test/shell/bazel/bazel_test_test.sh14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh
index 6db8b8340d..b7051798db 100755
--- a/src/test/shell/bazel/bazel_test_test.sh
+++ b/src/test/shell/bazel/bazel_test_test.sh
@@ -176,6 +176,9 @@ EOF
expect_log '1 test passes.$'
}
+# This test uses "--nomaster_bazelrc" since outside .bazelrc files can pollute
+# this environment and cause --experimental_ui to be turned on, which causes
+# this test to fail. Just "--bazelrc=/dev/null" is not sufficient to fix.
function test_run_under_path() {
mkdir -p testing || fail "mkdir testing failed"
echo "sh_test(name='t1', srcs=['t1.sh'])" > testing/BUILD
@@ -193,7 +196,7 @@ EOF
chmod u+x scripts/hello
# We don't just use the local PATH, but use the test's PATH, which is more restrictive.
- PATH=$PATH:$PWD/scripts bazel test //testing:t1 -s --run_under=hello \
+ PATH=$PATH:$PWD/scripts bazel --nomaster_bazelrc test //testing:t1 -s --run_under=hello \
--test_output=all >& $TEST_log && fail "Expected failure"
# We need to forward the PATH to make it work.
@@ -448,6 +451,9 @@ EOF
expect_log 'FAILED.*com\.example\.myproject\.Fail\.testFail'
}
+# This test uses "--nomaster_bazelrc" since outside .bazelrc files can pollute
+# this environment and cause --experimental_ui to be turned on, which causes
+# this test to fail. Just "--bazelrc=/dev/null" is not sufficient to fix.
function test_flaky_test() {
cat >BUILD <<EOF
sh_test(name = "flaky", flaky = True, srcs = ["flaky.sh"])
@@ -478,7 +484,7 @@ EOF
chmod +x true.sh flaky.sh false.sh
# We do not use sandboxing so we can trick to be deterministically flaky
- bazel test --spawn_strategy=standalone //:flaky &> $TEST_log \
+ bazel --nomaster_bazelrc test --spawn_strategy=standalone //:flaky &> $TEST_log \
|| fail "//:flaky should have passed with flaky support"
[ -f "${FLAKE_FILE}" ] || fail "Flaky test should have created the flake-file!"
@@ -491,7 +497,7 @@ EOF
cat bazel-testlogs/flaky/test.log &> $TEST_log
assert_equals "pass" "$(tail -1 bazel-testlogs/flaky/test.log)"
- bazel test //:pass &> $TEST_log \
+ bazel --nomaster_bazelrc test //:pass &> $TEST_log \
|| fail "//:pass should have passed"
expect_log_once "PASS: //:pass"
expect_log_once PASSED
@@ -500,7 +506,7 @@ EOF
cat bazel-testlogs/flaky/test.log &> $TEST_log
assert_equals "pass" "$(tail -1 bazel-testlogs/flaky/test.log)"
- bazel test //:fail &> $TEST_log \
+ bazel --nomaster_bazelrc test //:fail &> $TEST_log \
&& fail "//:fail should have failed" \
|| true
expect_log_n "FAIL: //:fail (.*/fail/test_attempts/attempt_..log)" 2