Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to latest Truth, and add surefire plugin to errorprone artifact #44

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions mug-errorprone/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,89 @@
</parent>
<artifactId>mug-errorprone</artifactId>
<name>Java Plugins</name>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.binarypb</include>
</includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<includes>
<include>**/testdata/**</include>
</includes>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.10.0</version>
<executions>
<execution>
<id>attach-descriptor</id>
<goals>
<goal>attach-descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<argLine>
-Xmx1g
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
--add-opens=java.base/java.math=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
</argLine>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.auto.service</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.google.mu.errorprone;

import com.google.common.collect.ImmutableMap;
import com.google.errorprone.bugpatterns.BugChecker;
import com.google.mu.util.Substring;
import com.google.mu.util.stream.BiStream;
import static com.google.mu.util.stream.GuavaCollectors.toImmutableMap;

/** Abstract class providing convenience to BugChecker implementations. */
abstract class AbstractBugChecker extends BugChecker {
private static final Substring.Pattern PLACEHOLDER = Substring.between('{', '}');
private static final ImmutableMap<?, ?> MAP = BiStream.empty().collect(toImmutableMap());

}
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ public class StructorTest {
@Test public void toValue_fromBoolean() {
assertThat(maker.toValue(true)).isEqualTo(Value.newBuilder().setBoolValue(true).build());
assertThat(maker.toValue(false)).isEqualTo(Value.newBuilder().setBoolValue(false).build());
assertThat(maker.toValue(true)).isSameAs(maker.toValue(true));
assertThat(maker.toValue(false)).isSameAs(maker.toValue(false));
assertThat(maker.toValue(true)).isSameInstanceAs(maker.toValue(true));
assertThat(maker.toValue(false)).isSameInstanceAs(maker.toValue(false));
}

@Test public void toValue_fromNull() {
assertThat(maker.toValue(null))
.isEqualTo(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build());
assertThat(maker.toValue(null)).isSameAs(maker.toValue(null));
assertThat(maker.toValue(null)).isSameInstanceAs(maker.toValue(null));
}

@Test public void toValue_fromEmptyOptional() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public class BiComparatorTest {

@Test public void testComparingInOrder_primaryOnly() {
BiComparator<?, ?> primary = comparingKey(Object::toString);
assertThat(BiComparator.comparingInOrder(primary)).isSameAs(primary);
assertThat(BiComparator.comparingInOrder(primary)).isSameInstanceAs(primary);
}

@Test public void testComparingInOrder_byValueThenByKey() {
Expand All @@ -164,7 +164,7 @@ public class BiComparatorTest {

@Test public void reversed_reversed() {
BiComparator<Object, Object> ordering = comparingKey(Object::toString);
assertThat(ordering.reversed().reversed()).isSameAs(ordering);
assertThat(ordering.reversed().reversed()).isSameInstanceAs(ordering);
}

@Test public void testNuls() {
Expand Down
8 changes: 4 additions & 4 deletions mug/src/test/java/com/google/mu/util/BiOptionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void initMocks() {
}

@Test public void empty_singleton() {
assertThat(BiOptional.empty()).isSameAs(BiOptional.empty());
assertThat(BiOptional.empty()).isSameInstanceAs(BiOptional.empty());
}

@Test public void map_empty() {
Expand Down Expand Up @@ -121,13 +121,13 @@ public void initMocks() {

@Test public void peek_nonEmpty() {
BiOptional<?, ?> optional = BiOptional.of("foo", "bar");
assertThat(optional.peek(consumer)).isSameAs(optional);
assertThat(optional.peek(consumer)).isSameInstanceAs(optional);
verify(consumer).accept("foo", "bar");
}

@Test public void orElse_peek_nonEmpty() {
BiOptional<String, String> optional = BiOptional.of("foo", "bar");
assertThat(optional.orElse("x", null).peek(consumer)).isSameAs(optional);
assertThat(optional.orElse("x", null).peek(consumer)).isSameInstanceAs(optional);
verify(consumer).accept("foo", "bar");
}

Expand Down Expand Up @@ -254,7 +254,7 @@ public void initMocks() {
@Test public void testOrElseThrow_empty() {
Exception e = new Exception("test");
Exception thrown = assertThrows(Exception.class, () -> BiOptional.empty().orElseThrow(() -> e));
assertThat(thrown).isSameAs(e);
assertThat(thrown).isSameInstanceAs(e);
}

@Test public void testOrElseThrow_notEmpty() {
Expand Down
2 changes: 1 addition & 1 deletion mug/src/test/java/com/google/mu/util/BothTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class BothTest {
@Test public void peek() {
AtomicInteger effect = new AtomicInteger();
Both<Integer, Integer> b = both(1, 2);
assertThat(b.peek((x, y) -> effect.set(x + y))).isSameAs(b);
assertThat(b.peek((x, y) -> effect.set(x + y))).isSameInstanceAs(b);
assertThat(effect.get()).isEqualTo(3);
}

Expand Down
Loading
Loading