Skip to content

Commit

Permalink
Support async tests for j2kt-native/j2kt-jvm
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 718340083
  • Loading branch information
stefanhaustein authored and copybara-github committed Jan 22, 2025
1 parent d117de1 commit 877b4a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#macro( methodExecution $classOrInstance $testMethod)
## TODO(b/270609553) to revisit this once j2cl (j2kt web) and j2cl kotlin tests support coroutines.
#if($testMethod.isAsync())
$classOrInstance.${testMethod.javaMethodName()}().get(${testMethod.timeout()}.toLong(), java.util.concurrent.TimeUnit.MILLISECONDS);
#else
$classOrInstance.${testMethod.javaMethodName()}();
#end
#end
#macro( methodExecutions $classOrInstance $testMethods)
#foreach($testMethod in $testMethods )
Expand Down
10 changes: 9 additions & 1 deletion junit/generator/java/com/google/j2cl/junit/async/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# testing under j2cl.
# JVM async testing support should be placed under Guava or Xplat.

load("//build_defs:rules.bzl", "j2cl_library")
load("//build_defs:rules.bzl", "j2cl_library", "j2kt_native_library")
load("@rules_java//java:defs.bzl", "java_library")

package(
Expand Down Expand Up @@ -38,3 +38,11 @@ j2cl_library(
"//third_party:junit-j2cl",
],
)

j2kt_native_library(
name = "async-j2kt-native",
testonly = 1,
srcs = [
"Timeout.java",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/** Defines a timeout for JUnit lifecycle methods. */
/** Defines a timeout for JUnit lifecycle methods in milliseconds. */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Timeout {
Expand Down

0 comments on commit 877b4a4

Please sign in to comment.