From a9f20b0d6459d395444c45cf5e94a899f3443633 Mon Sep 17 00:00:00 2001 From: Damien Martin-Guillerez Date: Tue, 18 Oct 2016 11:48:18 +0000 Subject: Enforce that non test-only targets cannot depends on test-only targets This behavior was not enforced since we open-sourced Bazel even though this was documented and the attributed existed. Also removed the incorrect part from the documentations: we do not enforce restrictions on javatests package. Fixes #1923. RELNOTES[INC]: Non test-only targets can no longer depends on test-only targets. -- MOS_MIGRATED_REVID=136459421 --- src/test/shell/bazel/bazel_test_test.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/test/shell/bazel/bazel_test_test.sh') diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh index 073a3a6949..b82562d6e7 100755 --- a/src/test/shell/bazel/bazel_test_test.sh +++ b/src/test/shell/bazel/bazel_test_test.sh @@ -293,6 +293,29 @@ EOF [ -s $xml_log ] || fail "$xml_log was not present after test" } +# Simple test that we actually enforce testonly, see #1923. +function test_testonly_is_enforced() { + mkdir -p testonly + cat <<'EOF' >testonly/BUILD +genrule( + name = "testonly", + srcs = [], + cmd = "echo testonly | tee $@", + outs = ["testonly.txt"], + testonly = 1, +) +genrule( + name = "not-testonly", + srcs = [":testonly"], + cmd = "echo should fail | tee $@", + outs = ["not-testonly.txt"], +) +EOF + bazel build //testonly &>$TEST_log || fail "Building //testonly failed" + bazel build //testonly:not-testonly &>$TEST_log && fail "Should have failed" || true + expect_log "'//testonly:not-testonly' depends on testonly target '//testonly:testonly'" +} + function test_always_xml_output() { mkdir -p dir -- cgit v1.2.3