Skip to content

Commit

Permalink
Enable ErrorProne tests under bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyutangyuan committed Nov 25, 2023
1 parent af13458 commit 6eb8f07
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 25 deletions.
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ maven_install(
"com.google.truth.extensions:truth-java8-extension:[1.1,)",
"org.checkerframework:checker-qual:3.12.0",
"com.google.auto.service:auto-service-annotations:1.1.1",
"com.google.auto.service:auto-service:1.1.1",
"com.google.protobuf:protobuf-java:[3.0.0,)",
"com.google.protobuf:protobuf-java-util:[3.0.0,)",
"com.google.code.findbugs:jsr305:3.0.2",
Expand Down
21 changes: 13 additions & 8 deletions mug-errorprone/BUILD
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
java_plugin(
name = "mug-errorprone",
deps = [":errorprone"],
)

java_library(
name = "errorprone",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"@maven//:com_google_guava_guava",
"@maven//:com_google_errorprone_error_prone_core",
"@maven//:com_google_errorprone_error_prone_annotation",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_errorprone_error_prone_check_api",
"@maven//:com_google_auto_service_auto_service_annotations",
"//mug",
"//mug:base",
"//mug-guava",
],
)

java_plugin(
name = "plugin",
processor_class = "com.google.auto.service.processor.AutoServiceProcessor",
visibility = ["//visibility:public"],
deps = [
":errorprone",
"@maven//:com_google_errorprone_error_prone_core",
"@maven//:com_google_auto_service_auto_service",
],
)

load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests")


junit_tests(
name = "AllTests",
srcs = glob(["src/test/java/**/*Test.java"]),
deps = [
":errorprone",
"//mug",
"//mug:format",
"@maven//:com_google_guava_guava",
"@maven//:com_google_guava_guava_testlib",
"@maven//:com_google_truth_truth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ public void scanAndCollectFromMethodChecked_withBiCollector() {
.doTest();
}

@Test
@Test
public void methodWithoutMapperParameterIsIgnored() {
helper
.addSourceLines(
Expand Down
17 changes: 17 additions & 0 deletions mug-examples/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests")


junit_tests(
name = "AllTests",
srcs = glob(["src/test/java/**/*Test.java"]),
deps = [
"//mug:base",
"//mug:format",
"//mug-guava",
"@maven//:com_google_guava_guava",
"@maven//:com_google_truth_truth",
"@maven//:com_google_truth_extensions_truth_java8_extension",
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:junit_junit",
],
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package examples;
package com.google.mu.examples;

import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package examples;
package com.google.mu.examples;

import static com.google.common.truth.Truth.assertThat;
import static com.google.mu.util.stream.BiStream.concat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package examples;
package com.google.mu.examples;

import static com.google.common.truth.Truth.assertThat;
import static com.google.mu.util.stream.BiStream.crossJoining;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package examples;
package com.google.mu.examples;

import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static com.google.common.truth.Truth.assertThat;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.google.mu.examples;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import com.google.mu.util.StringFormat;

@RunWith(JUnit4.class)
public class HowToUseStringFormatTest {

@Test public void testIt() {
}

private String badUsage() {
return new StringFormat("{key}:{value}").parseOrThrow("k:v", key -> key);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package examples;
package com.google.mu.examples;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat;
Expand Down
4 changes: 2 additions & 2 deletions mug-guava/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ java_library(
"@@maven//:com_google_guava_guava",
"@maven//:org_checkerframework_checker_qual",
"@maven//:com_google_errorprone_error_prone_annotations",
"//mug",
"//mug:base",
],
)

Expand All @@ -19,7 +19,7 @@ junit_tests(
srcs = glob(["src/test/java/**/*Test.java"]),
deps = [
":mug-guava",
"//mug",
"//mug:base",
"@maven//:com_google_guava_guava",
"@maven//:com_google_guava_guava_testlib",
"@maven//:com_google_truth_truth",
Expand Down
6 changes: 2 additions & 4 deletions mug-protobuf/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ java_library(
"@maven//:com_google_errorprone_error_prone_annotations",
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_google_protobuf_protobuf_java_util",
"//mug",
"//mug:base",
],
)



load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests")


Expand All @@ -22,7 +20,7 @@ junit_tests(
srcs = glob(["src/test/java/**/*Test.java"]),
deps = [
":mug-protobuf",
"//mug",
"//mug:base",
"//mug-guava",
"@maven//:com_google_guava_guava",
"@maven//:com_google_guava_guava_testlib",
Expand Down
40 changes: 35 additions & 5 deletions mug/BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
java_library(
name = "mug",
name = "base",
visibility = ["//visibility:public"],
srcs = glob(["src/main/java/**/*.java"]),
resources = glob(["src/main/resources/**"]),
srcs = glob([
"src/main/java/com/google/mu/util/*.java",
"src/main/java/com/google/mu/util/stream/*.java",
"src/main/java/com/google/mu/function/*.java",
],
exclude = ["src/main/java/com/google/mu/util/StringFormat.java"]),
)

java_library(
name = "graph",
visibility = ["//visibility:public"],
srcs = glob([ "src/main/java/com/google/mu/util/graph/*.java"]),
deps = [":base"]
)

java_library(
name = "concurrent",
visibility = ["//visibility:public"],
srcs = glob([ "src/main/java/com/google/mu/util/concurrent/*.java"]),
deps = [":base"]
)

java_library(
name = "format",
visibility = ["//visibility:public"],
srcs = ["src/main/java/com/google/mu/util/StringFormat.java"],
deps = [":base"],
exported_plugins = ["//mug-errorprone:plugin"],
)

load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests")
Expand All @@ -11,7 +37,8 @@ java_library(
name = "tests",
srcs = glob(["src/test/java/**/*.java"], exclude = glob(["src/test/java/**/*Test.java"])),
deps = [
":mug",
":base",
":concurrent",
"@maven//:com_google_guava_guava",
"@maven//:com_google_guava_guava_testlib",
"@maven//:com_google_truth_truth",
Expand All @@ -29,7 +56,10 @@ junit_tests(
name = "AllTests",
srcs = glob(["src/test/java/**/*Test.java"]),
deps = [
":mug",
":base",
":concurrent",
":format",
":graph",
":tests",
"@maven//:com_google_guava_guava",
"@maven//:com_google_guava_guava_testlib",
Expand Down

0 comments on commit 6eb8f07

Please sign in to comment.