Skip to content

Commit

Permalink
Move JVM testing under j2cl_multi_test.
Browse files Browse the repository at this point in the history
This makes test targets organized more consistently and avoids hand maintaining a separate suite.

PiperOrigin-RevId: 698462529
  • Loading branch information
gkdn authored and copybara-github committed Nov 20, 2024
1 parent cb38c54 commit e74135b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 47 deletions.
18 changes: 8 additions & 10 deletions jre/javatests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary")
load("//build_defs:rules.bzl", "j2cl_library", "j2cl_test", "j2kt_native_library", "j2wasm_test")
load("//third_party/bazel_rules/rules_closure/closure:defs.bzl", "closure_js_binary")
load("@rules_java//java:defs.bzl", "java_test")
load("@rules_java//java:defs.bzl", "java_library")
load(":j2cl_multi_test.bzl", "j2cl_multi_test")

package(
Expand All @@ -24,7 +24,7 @@ SRCS = glob(
)

j2cl_library(
name = "emul_tests_lib",
name = "emul_tests_lib-j2cl",
testonly = 1,
srcs = SRCS,
# Safe here as this is for tests only and there are no downstream users.
Expand Down Expand Up @@ -64,11 +64,9 @@ j2kt_native_library(
],
)

# This runs all test for emul in JVM, this way we can make sure that our tests
# assert the right behaviour for the JRE emulation.
java_test(
name = "AllEmulTest_Java",
size = "small",
java_library(
name = "emul_tests_lib",
testonly = 1,
srcs = SRCS,
javacopts = [
"-Xep:DoNotCall:OFF",
Expand All @@ -79,7 +77,6 @@ java_test(
"-Xep:SelfEquals:OFF",
"-Xep:ReturnValueIgnored:OFF",
],
test_class = "com.google.j2cl.jre.AllTests",
deps = [
"//jre/java:javaemul_internal_annotations",
"//third_party:jsinterop-annotations",
Expand Down Expand Up @@ -151,7 +148,7 @@ j2cl_multi_test(
)

j2cl_library(
name = "js_tests_lib",
name = "js_tests_lib-j2cl",
testonly = 1,
srcs = JS_ONLY_SRCS,
deps = [
Expand All @@ -163,6 +160,7 @@ j2cl_library(
j2cl_multi_test(
name = "JsSuite",
enable_j2kt_native = False,
enable_jvm = False,
enable_wasm = False,
test_class = "com.google.j2cl.jre.JsSuite",
deps = [":js_tests_lib"],
Expand All @@ -177,7 +175,7 @@ j2cl_test(
shard_count = 4,
test_class = "com.google.j2cl.jre.ConcurrentSuite",
runtime_deps = [
":emul_tests_lib",
":emul_tests_lib-j2cl",
"//third_party:junit-j2cl",
],
)
Expand Down
34 changes: 0 additions & 34 deletions jre/javatests/com/google/j2cl/jre/AllTests.java

This file was deleted.

16 changes: 13 additions & 3 deletions jre/javatests/j2cl_multi_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,38 @@ j2cl_multi_test(
"""

load("@rules_java//java:defs.bzl", "java_test")
load("//build_defs:rules.bzl", "j2cl_test", "j2kt_native_test", "j2wasm_test")

def j2cl_multi_test(name, test_class, deps, enable_j2kt_native = True, enable_wasm = True, **kwargs):
def j2cl_multi_test(name, test_class, deps, enable_jvm = True, enable_j2kt_native = True, enable_wasm = True, **kwargs):
j2cl_deps = [dep + "-j2cl" for dep in deps]
j2cl_test(
name = name,
test_class = test_class,
generate_build_test = False,
runtime_deps = deps,
runtime_deps = j2cl_deps,
**kwargs
)
j2cl_test(
name = name + "_compiled",
test_class = test_class,
compile = 1,
generate_build_test = False,
runtime_deps = deps,
runtime_deps = j2cl_deps,
browsers = [
"//build_defs/internal_do_not_use/browser:chrome-wasm-linux",
],
**kwargs
)

if enable_jvm:
java_test(
name = name + "-jvm",
test_class = test_class,
runtime_deps = deps,
**kwargs
)

if enable_wasm:
j2wasm_deps = [dep + "-j2wasm" for dep in deps]
j2wasm_defines = {"jre.checks.checkLevel": "NORMAL"}
Expand Down

0 comments on commit e74135b

Please sign in to comment.