From 66ab13fad654881ed3caccde7c9e0422b222e32e Mon Sep 17 00:00:00 2001 From: Googler Date: Mon, 25 Sep 2017 10:50:09 -0400 Subject: 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 --- src/test/shell/bazel/bazel_test_test.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') 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 < $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 -- cgit v1.2.3