Skip to content

Commit

Permalink
Add a new test entry point for running JRE tests in open source.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 702138127
  • Loading branch information
gkdn authored and copybara-github committed Dec 3, 2024
1 parent b72178b commit 1891f73
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions build_defs/internal_do_not_use/j2cl_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/...
Expand Down
12 changes: 12 additions & 0 deletions jre/javatests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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 <target>_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"],
Expand Down
5 changes: 3 additions & 2 deletions jre/javatests/com/google/j2cl/jre/java/lang/StringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 1891f73

Please sign in to comment.