1"""Utilities for Java brotli tests."""
2
3_TEST_JVM_FLAGS = [
4    "-DBROTLI_ENABLE_ASSERTS=true",
5]
6
7def brotli_java_test(name, main_class = None, jvm_flags = None, **kwargs):
8    """test duplication rule that creates 32/64-bit test pair."""
9
10    if jvm_flags == None:
11        jvm_flags = []
12    jvm_flags = jvm_flags + _TEST_JVM_FLAGS
13
14    test_package = native.package_name().replace("/", ".")
15    if main_class == None:
16        test_class = test_package + "." + name
17    else:
18        test_class = None
19
20    native.java_test(
21        name = name + "_32",
22        main_class = main_class,
23        test_class = test_class,
24        jvm_flags = jvm_flags + ["-DBROTLI_32_BIT_CPU=true"],
25        **kwargs
26    )
27
28    native.java_test(
29        name = name + "_64",
30        main_class = main_class,
31        test_class = test_class,
32        jvm_flags = jvm_flags + ["-DBROTLI_32_BIT_CPU=false"],
33        **kwargs
34    )
35