aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com
diff options
context:
space:
mode:
authorGravatar Tobias Werth <twerth@google.com>2016-09-22 11:19:24 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-09-22 11:54:25 +0000
commit5c548f11e20c0b75203e9fe4ab682ed0418064cf (patch)
treef9d5073443fd66135189aa2fe2622cee2ead1377 /src/test/java/com
parent36395c417899bd4009efc3a6cda5ea838f3d98ef (diff)
*** Reason for rollback *** Breaks some targets in the nightly: see [] *** Original change description *** Make java_proto_library's strict_deps default to true. Remove package-level attribute to set the default of strict_deps. Change the semantics to --strict_deps_java_protos to mean force strict deps of all Java protos to be true regardless of their strict_deps attribute. -- MOS_MIGRATED_REVID=133938648
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/java/proto/StrictDepsUtilsTest.java68
1 files changed, 66 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/java/proto/StrictDepsUtilsTest.java b/src/test/java/com/google/devtools/build/lib/rules/java/proto/StrictDepsUtilsTest.java
index df6c1d9f36..7a6c3b8989 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/java/proto/StrictDepsUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/java/proto/StrictDepsUtilsTest.java
@@ -35,12 +35,44 @@ public class StrictDepsUtilsTest extends BuildViewTestCase {
"java_proto_library(name = 'b', strict_deps = 0)",
"java_proto_library(name = 'c', strict_deps = 1)");
- assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//x:a"))).isTrue();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//x:a"))).isFalse();
assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//x:b"))).isFalse();
assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//x:c"))).isTrue();
}
@Test
+ public void isStrictDepsJavaProtoLibrary_flagIsFalse_packageLevelIs0() throws Exception {
+ useConfiguration("--strict_deps_java_protos=false");
+
+ scratch.file(
+ "y/BUILD",
+ "package(default_strict_deps_java_protos = 0)",
+ "java_proto_library(name = 'a')",
+ "java_proto_library(name = 'b', strict_deps = 0)",
+ "java_proto_library(name = 'c', strict_deps = 1)");
+
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//y:a"))).isFalse();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//y:b"))).isFalse();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//y:c"))).isTrue();
+ }
+
+ @Test
+ public void isStrictDepsJavaProtoLibrary_flagIsFalse_packageLevelIs1() throws Exception {
+ useConfiguration("--strict_deps_java_protos=false");
+
+ scratch.file(
+ "z/BUILD",
+ "package(default_strict_deps_java_protos = 1)",
+ "java_proto_library(name = 'a')",
+ "java_proto_library(name = 'b', strict_deps = 0)",
+ "java_proto_library(name = 'c', strict_deps = 1)");
+
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//z:a"))).isTrue();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//z:b"))).isFalse();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//z:c"))).isTrue();
+ }
+
+ @Test
public void isStrictDepsJavaProtoLibrary_flagIsTrue_noPackageLevelAttribute() throws Exception {
useConfiguration("--strict_deps_java_protos=true");
@@ -51,10 +83,42 @@ public class StrictDepsUtilsTest extends BuildViewTestCase {
"java_proto_library(name = 'c', strict_deps = 1)");
assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//x:a"))).isTrue();
- assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//x:b"))).isTrue();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//x:b"))).isFalse();
assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//x:c"))).isTrue();
}
+ @Test
+ public void isStrictDepsJavaProtoLibrary_flagIsTrue_packageLevelIs0() throws Exception {
+ useConfiguration("--strict_deps_java_protos=true");
+
+ scratch.file(
+ "y/BUILD",
+ "package(default_strict_deps_java_protos = 0)",
+ "java_proto_library(name = 'a')",
+ "java_proto_library(name = 'b', strict_deps = 0)",
+ "java_proto_library(name = 'c', strict_deps = 1)");
+
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//y:a"))).isFalse();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//y:b"))).isFalse();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//y:c"))).isTrue();
+ }
+
+ @Test
+ public void isStrictDepsJavaProtoLibrary_flagIsTrue_packageLevelIs1() throws Exception {
+ useConfiguration("--strict_deps_java_protos=true");
+
+ scratch.file(
+ "z/BUILD",
+ "package(default_strict_deps_java_protos = 1)",
+ "java_proto_library(name = 'a')",
+ "java_proto_library(name = 'b', strict_deps = 0)",
+ "java_proto_library(name = 'c', strict_deps = 1)");
+
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//z:a"))).isTrue();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//z:b"))).isFalse();
+ assertThat(StrictDepsUtils.isStrictDepsJavaProtoLibrary(getRuleContext("//z:c"))).isTrue();
+ }
+
private RuleContext getRuleContext(String label) throws Exception {
return getRuleContext(getConfiguredTarget(label));
}