Skip to content

Commit

Permalink
Fix javacopts for guice tests to also set --source 11
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 720748642
  • Loading branch information
lukesandberg authored and Guice Team committed Jan 29, 2025
1 parent 2a17feb commit c583c65
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/actions/bazel-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ runs:
restore-keys: |
${{ runner.os }}-java-${{matrix.java}}-bazel-test-
- name: Bazel test
run: bazel test //... --test_output=errors
run: bazel test --javacopt="--release 11" //... --test_output=errors
shell: bash
12 changes: 9 additions & 3 deletions core/test/com/google/inject/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Author: sameb@google.com (Sam Berlin)

load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -17,14 +18,19 @@ ADD_OPENS_SRCS = [
"ImplicitBindingJdkPackagePrivateTest.java",
]

TEST_JAVAC_OPTS = [
"-Xep:BetaApi:OFF",
"-Xdoclint:none",
] + JAVAC_OPTS

# Files that are shared by extensions also.
# Typically this would go in a java/../testing package,
# but we need to work with the open-source code structure,
# so it is here.
java_library(
name = "testsupport",
srcs = TEST_SUPPORT_SRCS,
javacopts = ["-Xep:BetaApi:OFF"],
javacopts = TEST_JAVAC_OPTS,
visibility = [
"//:src",
],
Expand All @@ -47,7 +53,7 @@ java_library(
"AllTests.java",
],
),
javacopts = ["-Xep:BetaApi:OFF"],
javacopts = TEST_JAVAC_OPTS,
deps = [
":testsupport",
"//core/src/com/google/inject",
Expand All @@ -66,7 +72,7 @@ java_library(
java_library(
name = "add_opens_tests",
srcs = ADD_OPENS_SRCS,
javacopts = ["-Xep:BetaApi:OFF"],
javacopts = TEST_JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//third_party/java/guava/base",
Expand Down
4 changes: 2 additions & 2 deletions core/test/com/google/inject/ImplicitBindingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void go() {}
* dependencies. And so we can successfully create a binding for B. But later, when the binding
* for A ultimately fails, we need to clean up the dependent binding for B.
*
* <p>The test loops through linked bindings & bindings with constructor and member injections, to
* make sure that all are cleaned up and traversed. It also makes sure we don't touch explicit
* <p>The test loops through linked bindings and bindings with constructor and member injections,
* to make sure that all are cleaned up and traversed. It also makes sure we don't touch explicit
* bindings.
*/
public void testCircularJitBindingsLeaveNoResidue() {
Expand Down
2 changes: 1 addition & 1 deletion core/test/com/google/inject/KeyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void testTypeEquality() throws Exception {
}

/**
* Key canonicalizes {@link int.class} to {@code Integer.class}, and won't expose wrapper types.
* Key canonicalizes {@code int.class} to {@code Integer.class}, and won't expose wrapper types.
*/
@SuppressWarnings("rawtypes") // Unavoidable because class literal uses raw type
public void testPrimitivesAndWrappersAreEqual() {
Expand Down
4 changes: 3 additions & 1 deletion core/test/com/google/inject/errors/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -10,6 +11,7 @@ ERROR_MESSAGE_TEST_UTILS_SRCS = ["ErrorMessageTestUtils.java"]
java_library(
name = "error_message_test_utils",
srcs = ERROR_MESSAGE_TEST_UTILS_SRCS,
javacopts = JAVAC_OPTS,
deps = [
"//third_party/java/guava/io",
"//third_party/java/truth",
Expand All @@ -22,7 +24,7 @@ java_library(
["*.java"],
exclude = ERROR_MESSAGE_TEST_UTILS_SRCS,
),
javacopts = ["-Xep:BetaApi:OFF"],
javacopts = ["-Xep:BetaApi:OFF"] + JAVAC_OPTS,
resources = [
":test_error_files",
],
Expand Down
2 changes: 2 additions & 0 deletions core/test/com/googlecode/guice/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Author: sameb@google.com (Sam Berlin)

load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -15,6 +16,7 @@ java_library(
["**/*.java"],
exclude = ["*Tck.java"],
),
javacopts = JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//core/test/com/google/inject:testsupport",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2011 Google Inc. All rights reserved.
# Author: sameb@google.com (Sam Berlin)
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -15,6 +16,7 @@ java_library(
"subpkg/SubpackageTestPrivateFallbackOnly.java",
],
),
javacopts = JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//core/test/com/google/inject:testsupport",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2015 Google Inc. All rights reserved.
# Author: cgruber@google.com (Christian Gruber)
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -10,6 +11,7 @@ package(
java_library(
name = "tests",
srcs = glob(["**/*.java"]),
javacopts = JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//extensions/dagger-adapter/src/com/google/inject/daggeradapter",
Expand Down
2 changes: 2 additions & 0 deletions extensions/grapher/test/com/google/inject/grapher/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2011 Google Inc. All rights reserved.
# Author: sameb@google.com (Sam Berlin)
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -10,6 +11,7 @@ package(
java_library(
name = "tests",
srcs = glob(["**/*.java"]),
javacopts = JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//extensions/assistedinject/src/com/google/inject/assistedinject",
Expand Down
2 changes: 2 additions & 0 deletions extensions/jmx/test/com/google/inject/tools/jmx/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2011 Google Inc. All rights reserved.
# Author: sameb@google.com (Sam Berlin)
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")

package(
default_testonly = 1,
Expand All @@ -9,6 +10,7 @@ package(
java_library(
name = "tests",
srcs = glob(["**/*.java"]),
javacopts = JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//extensions/jmx/src/com/google/inject/tools/jmx",
Expand Down
3 changes: 2 additions & 1 deletion extensions/servlet/test/com/google/inject/servlet/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2011 Google Inc. All rights reserved.
# Author: sameb@google.com (Sam Berlin)
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -13,7 +14,7 @@ java_library(
javacopts = [
"-Xep:FutureReturnValueIgnored:OFF",
"-Xep:MixedArrayDimensions:OFF",
],
] + JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//core/test/com/google/inject:testsupport",
Expand Down
2 changes: 2 additions & 0 deletions extensions/spring/test/com/google/inject/spring/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2011 Google Inc. All rights reserved.
# Author: sameb@google.com (Sam Berlin)
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -10,6 +11,7 @@ package(
java_library(
name = "tests",
srcs = glob(["**/*.java"]),
javacopts = JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//extensions/spring/src/com/google/inject/spring",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2014 Google Inc. All rights reserved.
# Author: eatnumber1@google.com (Russ Harmon)
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -10,6 +11,7 @@ package(
java_library(
name = "tests",
srcs = glob(["*.java"]),
javacopts = JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//core/test/com/google/inject:testsupport",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -8,6 +9,7 @@ package(
java_library(
name = "tests",
srcs = glob(["*.java"]),
javacopts = JAVAC_OPTS,
deps = [
"//extensions/testlib/src/com/google/inject/testing/throwingproviders",
"//extensions/throwingproviders/src/com/google/inject/throwingproviders",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2011 Google Inc. All rights reserved.
# Author: sameb@google.com (Sam Berlin)
load("@rules_java//java:defs.bzl", "java_library")
load("//:build_defs.bzl", "JAVAC_OPTS")
load("//:test_defs.bzl", "guice_test_suites")

package(
Expand All @@ -10,6 +11,7 @@ package(
java_library(
name = "tests",
srcs = glob(["**/*.java"]),
javacopts = JAVAC_OPTS,
deps = [
"//core/src/com/google/inject",
"//core/test/com/google/inject:testsupport",
Expand Down

0 comments on commit c583c65

Please sign in to comment.