8000 Make xla_cc_test default to shuffling test cases. · linux-on-ibm-z/tensorflow@ea61820 · GitHub
[go: up one dir, main page]

Skip to content

Commit ea61820

Browse files
Make xla_cc_test default to shuffling test cases.
This helps catch test case order dependencies at presubmit time. PiperOrigin-RevId: 730500863
1 parent ed0d218 commit ea61820

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

third_party/xla/xla/backends/cpu/runtime/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ cc_library(
150150
xla_cc_test(
151151
name = "object_pool_test",
152152
srcs = ["object_pool_test.cc"],
153+
shuffle_tests = False,
153154
deps = [
154155
":object_pool",
155156
"//xla/tsl/platform:env",

third_party/xla/xla/ffi/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ xla_cc_test(
210210
srcs = ["ffi_test.cc"],
211211
copts = ["-fexceptions"],
212212
features = ["-use_header_modules"],
213+
shuffle_tests = False,
213214
deps = [
214215
":call_frame",
215216
":execution_context",

third_party/xla/xla/python/ifrt_proxy/common/ifrt_proxy.bzl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
load("//xla:xla.bzl", "xla_cc_test")
44

5-
def ifrt_proxy_cc_test(**kwargs):
6-
xla_cc_test(**kwargs)
5+
def ifrt_proxy_cc_test(
6+
shuffle_tests = False,
7+
**kwargs):
8+
xla_cc_test(
9+
shuffle_tests = shuffle_tests,
10+
**kwargs
11+
)
712

813
default_ifrt_proxy_visibility = ["//xla/python/ifrt_proxy:__subpackages__"]
914

third_party/xla/xla/python/ifrt_proxy/integration_tests/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ ifrt_proxy_cc_test(
6969
name = "executable_impl_test_tfrt_cpu",
7070
timeout = "moderate",
7171
srcs = ["executable_impl_test_tfrt_cpu.cc"],
72+
shuffle_tests = False,
7273
deps = [
7374
":register_pjrt_cpu_for_ifrt_api_tests", # buildcleaner: keep
7475
"//xla/python/ifrt:test_util",

third_party/xla/xla/tests/build_defs.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def xla_test(
192192
backend_args = {},
193193
backend_kwargs = {},
194194
linkstatic = False,
195+
shuffle_tests = False,
195196
**kwargs):
196197
"""Generates cc_test targets for the given XLA backends.
197198
@@ -262,6 +263,7 @@ def xla_test(
262263
arguments to pass to native.cc_test. Only use for kwargs that don't have a
263264
dedicated argument, like setting per-backend flaky or timeout attributes.
264265
linkstatic: Whether to link the test statically.
266+
shuffle_tests: Whether to shuffle the test cases.
265267
**kwargs: Additional keyword arguments to pass to native.cc_test.
266268
"""
267269

@@ -342,6 +344,7 @@ def xla_test(
342344
deps = deps + backend_deps,
343345
data = data + this_backend_data,
344346
linkstatic = linkstatic,
347+
shuffle_tests = shuffle_tests,
345348
**this_backend_kwargs
346349
)
347350

third_party/xla/xla/tsl/mkl/graph.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,15 @@ def onednn_graph_cc_library(srcs = [], hdrs = [], deps = [], **kwargs):
1717
**kwargs
1818
)
1919

20-
def onednn_graph_cc_test(srcs = [], deps = [], **kwargs):
20+
def onednn_graph_cc_test(
21+
srcs = [],
22+
deps = [],
23+
shuffle_tests = False,
24+
**kwargs):
2125
"""xla_cc_test rule that has empty src and deps if not building with Graph API."""
2226
xla_cc_test(
2327
srcs = if_graph_api(srcs),
2428
deps = if_graph_api(deps) + ["@com_google_googletest//:gtest_main"],
29+
shuffle_tests = shuffle_tests,
2530
**kwargs
2631
)

third_party/xla/xla/xla.bzl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,40 @@ _XLA_SHARED_OBJECT_SENSITIVE_DEPS = if_static(extra_deps = [], otherwise = [
7171
def xla_cc_binary(deps = [], copts = tsl_copts(), **kwargs):
7272
native.cc_binary(deps = deps + _XLA_SHARED_OBJECT_SENSITIVE_DEPS, copts = copts, **kwargs)
7373

74-
def xla_cc_test(name, deps = [], linkstatic = True, **kwargs):
74+
def xla_cc_test(
75+
name,
76+
deps = [],
77+
linkstatic = True,
78+
args = None,
79+
shuffle_tests = True,
80+
**kwargs):
7581
"""A wrapper around cc_test that adds XLA-specific dependencies.
7682
7783
Also, it sets linkstatic to True by default, which is a good practice for catching duplicate
7884
symbols at link time (e.g. linking in two main() functions).
7985
8086
Use xla_cc_test or xla_test instead of cc_test in all .../xla/... directories except .../tsl/...,
8187
where tsl_cc_test should be used.
88+
89+
Args:
90+
name: The name of the test.
91+
deps: The dependencies of the test.
92+
linkstatic: Whether to link statically.
93+
args: The arguments to pass to the test.
94+
shuffle_tests: Whether to shuffle the test cases.
95+
**kwargs: Other arguments to pass to the test.
8296
"""
8397

98+
if args == None:
99+
args = []
100+
101+
if shuffle_tests:
102+
# Shuffle tests to avoid test ordering dependencies.
103+
args = args + ["--gtest_shuffle"]
104+
84105
native.cc_test(
85106
name = name,
107+
args = args,
86108
deps = deps + _XLA_SHARED_OBJECT_SENSITIVE_DEPS,
87109
linkstatic = linkstatic,
88110
exec_properties = tf_exec_properties(kwargs),

0 commit comments

Comments
 (0)
0