aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell/bazel/bazel_test_test.sh
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-10-18 11:48:18 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-10-19 08:24:35 +0000
commita9f20b0d6459d395444c45cf5e94a899f3443633 (patch)
tree5dc25eb652fb15144110b838f25218918eb17897 /src/test/shell/bazel/bazel_test_test.sh
parentab588d21db260ed99ae1c9b6329eba099dc647dd (diff)
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
Diffstat (limited to 'src/test/shell/bazel/bazel_test_test.sh')
-rwxr-xr-xsrc/test/shell/bazel/bazel_test_test.sh23
1 files changed, 23 insertions, 0 deletions
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