From c6370e8a8b5989886ec763ea4dc8d5ce015ef5d7 Mon Sep 17 00:00:00 2001 From: cushon Date: Tue, 16 Apr 2019 11:57:15 -0700 Subject: [PATCH] Fix handling of test protos ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=243851753 --- core/pom.xml | 11 +++++++++++ .../bugpatterns/MixedDescriptorsTest.java | 3 --- .../bugpatterns/ModifiedButNotUsedTest.java | 14 ++++++-------- .../bugpatterns/ProtoFieldNullComparisonTest.java | 3 --- .../bugpatterns/ProtoRedundantSetTest.java | 3 --- .../ProtoTruthMixedDescriptorsTest.java | 3 --- .../bugpatterns/ProtocolBufferOrdinalTest.java | 3 --- .../bugpatterns/ReferenceEqualityTest.java | 4 +--- .../SizeGreaterThanOrEqualsZeroTest.java | 3 --- .../time/ProtoDurationGetSecondsGetNanoTest.java | 3 --- .../time/ProtoTimestampGetSecondsGetNanoTest.java | 3 --- .../time => proto}/durationtimestamp.proto | 0 .../testdata => }/proto/proto3_test.proto | 0 .../testdata => }/proto/proto_test.proto | 5 ++++- .../bugpatterns/threadsafety => proto}/test.proto | 4 ++-- pom.xml | 2 +- 16 files changed, 25 insertions(+), 39 deletions(-) rename core/src/test/{java/com/google/errorprone/bugpatterns/time => proto}/durationtimestamp.proto (100%) rename core/src/test/{java/com/google/errorprone/bugpatterns/testdata => }/proto/proto3_test.proto (100%) rename core/src/test/{java/com/google/errorprone/bugpatterns/testdata => }/proto/proto_test.proto (94%) rename core/src/test/{java/com/google/errorprone/bugpatterns/threadsafety => proto}/test.proto (58%) diff --git a/core/pom.xml b/core/pom.xml index 8562ac2c363..e214cadc33e 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -182,6 +182,13 @@ ${truth.version} test + + + com.google.truth.extensions + truth-proto-extension + ${truth.version} + test + com.google.inject @@ -390,6 +397,8 @@ protobuf-maven-plugin 0.5.1 + src/main/proto + src/test/proto com.google.protobuf:protoc:3.4.0:exe:${os.detected.classifier} grpc-java io.grpc:protoc-gen-grpc-java:1.0.1:exe:${os.detected.classifier} @@ -399,6 +408,8 @@ compile compile-custom + test-compile + test-compile-custom diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/MixedDescriptorsTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/MixedDescriptorsTest.java index 2d60851318b..8e91c1348e0 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/MixedDescriptorsTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/MixedDescriptorsTest.java @@ -21,14 +21,11 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** * Tests for {@link MixedDescriptors} bugpattern. * * @author ghm@google.com (Graeme Morgan) */ -@Ignore("b/74365407 test proto sources are broken") @RunWith(JUnit4.class) public final class MixedDescriptorsTest { private final CompilationTestHelper compilationHelper = diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/ModifiedButNotUsedTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/ModifiedButNotUsedTest.java index 8dcfaa804b6..c53404c2d69 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/ModifiedButNotUsedTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/ModifiedButNotUsedTest.java @@ -23,8 +23,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** * Tests for {@link ModifiedButNotUsed} bugpattern. * @@ -203,7 +201,7 @@ public void negativeAfterReassignment() { } @Test - @Ignore("b/74365407 test proto sources are broken") + public void proto() { compilationHelper .addSourceLines( @@ -227,7 +225,7 @@ public void proto() { } @Test - @Ignore("b/74365407 test proto sources are broken") + public void protoSideEffects() { refactoringHelper .addInputLines( @@ -258,7 +256,7 @@ public void protoSideEffects() { } @Test - @Ignore("b/74365407 test proto sources are broken") + public void protoNegative() { compilationHelper .addSourceLines( @@ -294,7 +292,7 @@ public void immutableCollection() { } @Test - @Ignore("b/74365407 test proto sources are broken") + public void protoUnusedExpression() { compilationHelper .addSourceLines( @@ -313,7 +311,7 @@ public void protoUnusedExpression() { } @Test - @Ignore("b/74365407 test proto sources are broken") + public void protoUnusedButNotModified() { compilationHelper .addSourceLines( @@ -330,7 +328,7 @@ public void protoUnusedButNotModified() { } @Test - @Ignore("b/74365407 test proto sources are broken") + public void protoUnusedExpressionViaBuilderGetter() { compilationHelper .addSourceLines( diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/ProtoFieldNullComparisonTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/ProtoFieldNullComparisonTest.java index 5d4595617cc..29e6e0dd9f9 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/ProtoFieldNullComparisonTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/ProtoFieldNullComparisonTest.java @@ -20,10 +20,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** @author flx@google.com (Felix Berger) */ -@Ignore("b/74365407 test proto sources are broken") @RunWith(JUnit4.class) public final class ProtoFieldNullComparisonTest { diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/ProtoRedundantSetTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/ProtoRedundantSetTest.java index 6299480cb94..29af5b24695 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/ProtoRedundantSetTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/ProtoRedundantSetTest.java @@ -23,14 +23,11 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** * Tests for {@link ProtoRedundantSet} bugpattern. * * @author ghm@google.com (Graeme Morgan) */ -@Ignore("b/74365407 test proto sources are broken") @RunWith(JUnit4.class) public final class ProtoRedundantSetTest { private final CompilationTestHelper compilationHelper = diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/ProtoTruthMixedDescriptorsTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/ProtoTruthMixedDescriptorsTest.java index 7e2812684ec..fdd515a3860 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/ProtoTruthMixedDescriptorsTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/ProtoTruthMixedDescriptorsTest.java @@ -21,14 +21,11 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** * Tests for {@link ProtoTruthMixedDescriptors} bugpattern. * * @author ghm@google.com (Graeme Morgan) */ -@Ignore("b/74365407 test proto sources are broken") @RunWith(JUnit4.class) public final class ProtoTruthMixedDescriptorsTest { private final CompilationTestHelper compilationHelper = diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/ProtocolBufferOrdinalTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/ProtocolBufferOrdinalTest.java index d269b689668..fe7d5dd2660 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/ProtocolBufferOrdinalTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/ProtocolBufferOrdinalTest.java @@ -22,14 +22,11 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** * Tests for {@link ProtocolBufferOrdinal}. * * @author bhagwani@google.com (Sumit Bhagwani) */ -@Ignore("b/74365407 test proto sources are broken") @RunWith(JUnit4.class) public class ProtocolBufferOrdinalTest { diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/ReferenceEqualityTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/ReferenceEqualityTest.java index ba9249db6a3..36bc7b68f20 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/ReferenceEqualityTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/ReferenceEqualityTest.java @@ -22,8 +22,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** {@link ReferenceEquality}Test */ @RunWith(JUnit4.class) public class ReferenceEqualityTest { @@ -33,7 +31,7 @@ public class ReferenceEqualityTest { private final BugCheckerRefactoringTestHelper refactoringTestHelper = BugCheckerRefactoringTestHelper.newInstance(new ReferenceEquality(), getClass()); - @Ignore("b/74365407 test proto sources are broken") + @Test public void protoGetter_nonnull() { compilationHelper diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/SizeGreaterThanOrEqualsZeroTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/SizeGreaterThanOrEqualsZeroTest.java index f0c566b67ee..fe9961eb8bb 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/SizeGreaterThanOrEqualsZeroTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/SizeGreaterThanOrEqualsZeroTest.java @@ -22,10 +22,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** Unit tests for {@link com.google.errorprone.bugpatterns.SizeGreaterThanOrEqualsZero} */ -@Ignore("b/74365407 test proto sources are broken") @RunWith(JUnit4.class) public class SizeGreaterThanOrEqualsZeroTest { CompilationTestHelper compilationHelper; diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/time/ProtoDurationGetSecondsGetNanoTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/time/ProtoDurationGetSecondsGetNanoTest.java index 08658410209..072f9badbb7 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/time/ProtoDurationGetSecondsGetNanoTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/time/ProtoDurationGetSecondsGetNanoTest.java @@ -21,14 +21,11 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** * Tests for {@link ProtoDurationGetSecondsGetNano}. * * @author kak@google.com (Kurt Alfred Kluever) */ -@Ignore("b/74365407 test proto sources are broken") @RunWith(JUnit4.class) public class ProtoDurationGetSecondsGetNanoTest { diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/time/ProtoTimestampGetSecondsGetNanoTest.java b/core/src/test/java/com/google/errorprone/bugpatterns/time/ProtoTimestampGetSecondsGetNanoTest.java index d3215bd4240..272714acf34 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/time/ProtoTimestampGetSecondsGetNanoTest.java +++ b/core/src/test/java/com/google/errorprone/bugpatterns/time/ProtoTimestampGetSecondsGetNanoTest.java @@ -21,14 +21,11 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.junit.Ignore; - /** * Tests for {@link ProtoTimestampGetSecondsGetNano}. * * @author kak@google.com (Kurt Alfred Kluever) */ -@Ignore("b/74365407 test proto sources are broken") @RunWith(JUnit4.class) public class ProtoTimestampGetSecondsGetNanoTest { diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/time/durationtimestamp.proto b/core/src/test/proto/durationtimestamp.proto similarity index 100% rename from core/src/test/java/com/google/errorprone/bugpatterns/time/durationtimestamp.proto rename to core/src/test/proto/durationtimestamp.proto diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/testdata/proto/proto3_test.proto b/core/src/test/proto/proto3_test.proto similarity index 100% rename from core/src/test/java/com/google/errorprone/bugpatterns/testdata/proto/proto3_test.proto rename to core/src/test/proto/proto3_test.proto diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/testdata/proto/proto_test.proto b/core/src/test/proto/proto_test.proto similarity index 94% rename from core/src/test/java/com/google/errorprone/bugpatterns/testdata/proto/proto_test.proto rename to core/src/test/proto/proto_test.proto index f4b14e1b219..bb74c1a0d01 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/testdata/proto/proto_test.proto +++ b/core/src/test/proto/proto_test.proto @@ -32,4 +32,7 @@ message TestProtoMessage { extensions 100 to 199; } -enum TestEnum { TEST_ENUM_VAL = 1; } +enum TestEnum { + UNSPECIFIED = 0; + TEST_ENUM_VAL = 1; +} diff --git a/core/src/test/java/com/google/errorprone/bugpatterns/threadsafety/test.proto b/core/src/test/proto/test.proto similarity index 58% rename from core/src/test/java/com/google/errorprone/bugpatterns/threadsafety/test.proto rename to core/src/test/proto/test.proto index 2a2b5e4c79f..8462097f03b 100644 --- a/core/src/test/java/com/google/errorprone/bugpatterns/threadsafety/test.proto +++ b/core/src/test/proto/test.proto @@ -2,8 +2,8 @@ syntax = "proto2"; package test; option java_package = "com.google.errorprone.testdata.proto"; -option java_mutable_api = true; -option java_enable_dual_generate_mutable_api = true; +option java_mutable_api = true; // MOE:strip_line +option java_enable_dual_generate_mutable_api = true; // MOE:strip_line message User { optional string name = 1; diff --git a/pom.xml b/pom.xml index be4895abfa7..9df63088b37 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ UTF-8 27.0.1-jre 2.8.2 - 0.36 + 0.42 9+181-r4173-1 1.5.3 4.13-beta-1