From 1891f73b92ffebce86b6c761824b08317ee24e34 Mon Sep 17 00:00:00 2001 From: Goktug Gokdogan Date: Mon, 2 Dec 2024 17:34:15 -0800 Subject: [PATCH] Add a new test entry point for running JRE tests in open source. PiperOrigin-RevId: 702138127 --- build_defs/internal_do_not_use/j2cl_library.bzl | 1 + build_test.sh | 3 +++ jre/javatests/BUILD | 12 ++++++++++++ .../com/google/j2cl/jre/java/lang/StringTest.java | 5 +++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/build_defs/internal_do_not_use/j2cl_library.bzl b/build_defs/internal_do_not_use/j2cl_library.bzl index 4c77d047c0..f929fe561f 100644 --- a/build_defs/internal_do_not_use/j2cl_library.bzl +++ b/build_defs/internal_do_not_use/j2cl_library.bzl @@ -122,6 +122,7 @@ _J2WASM_PACKAGES = [ "third_party/java_src/j2cl", "build_defs/internal_do_not_use", "junit", + "jre", "samples", "third_party", "third_party/java_src/jsr330_inject", diff --git a/build_test.sh b/build_test.sh index cdd48d62c3..2d569ff775 100755 --- a/build_test.sh +++ b/build_test.sh @@ -21,6 +21,9 @@ bazel build :all {jre,transpiler,tools,benchmarking,junit/generator,junit/emul}/ # Do a quick smoke check of integration test bazel test transpiler/javatests/com/google/j2cl/integration/java/emptyclass/... +# Run OpenSourceJRE test +bazel test jre/javatests:OpenSourceJre + # Run CI test if requested if [[ $1 == "CI" ]]; then bazel test transpiler/javatests/com/google/j2cl/integration/... diff --git a/jre/javatests/BUILD b/jre/javatests/BUILD index ea7d9deacb..510e0e914f 100644 --- a/jre/javatests/BUILD +++ b/jre/javatests/BUILD @@ -190,6 +190,18 @@ j2wasm_test( ], ) +# A test entry point for running JRE tests in open source. +# To run the test for all platforms: +# bazel test //jre/javatests:OpenSourceJre +# To debug a failing web test target, bazel run _debug. e.g. +# bazel run //jre/javatests:OpenSourceJre-j2cl_debug +j2cl_multi_test( + name = "OpenSourceJre", + # Please change the tested class here. + test_class = "com.google.j2cl.jre.java.lang.StringTest", + deps = [":emul_tests_lib"], +) + build_test( name = "conformance_test", tags = ["j2cl"], diff --git a/jre/javatests/com/google/j2cl/jre/java/lang/StringTest.java b/jre/javatests/com/google/j2cl/jre/java/lang/StringTest.java index bf0acc3a4b..674c501772 100644 --- a/jre/javatests/com/google/j2cl/jre/java/lang/StringTest.java +++ b/jre/javatests/com/google/j2cl/jre/java/lang/StringTest.java @@ -860,8 +860,9 @@ public static void testIndexOfNull() { } try { - returnNull().indexOf(""); - fail(); + int index = returnNull().indexOf(""); + // Use return value to avoid side-effect to be ignored by JSC. + fail(String.valueOf(index)); } catch (NullPointerException e) { // expected }