blob: 17672ffb5681893fbfeb463d2fe08e7f5c5e0441 [file] [log] [blame]
Devin Jeanpierrec503d332023-04-26 11:28:11 -07001# Part of the Crubit project, under the Apache License v2.0 with LLVM
2# Exceptions. See /LICENSE for license information.
3# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4"""Supporting macro for multiplatform code."""
5
Jing Lu4e940f92023-08-25 09:21:40 -07006load("//common:crubit_wrapper_macros_oss.bzl", "crubit_rust_test")
Devin Jeanpierrec503d332023-04-26 11:28:11 -07007
8_PLATFORMS = [
9 "x86_linux",
10 "arm_linux",
11]
12
13def multiplatform_rust_test(name, **kwargs):
14 """Macro to parameterize a test target by target platform."""
15
16 # TODO(jeanpierreda): Ideally we'd use `.`, not `-`, but this breaks for non-crate= rust_test targets
17 # because they create a crate with `.` in the name. That's illegal.
18 native.test_suite(
19 name = name,
20 tests = [name + "-" + platform for platform in _PLATFORMS],
21 )
22 rustc_env = kwargs.setdefault("env", {})
23 for platform in _PLATFORMS:
24 rustc_env["CRUBIT_TEST_PLATFORM"] = platform
25 test_name = name + "-" + platform
Jing Lu6c8b8a82023-08-25 06:42:35 -070026 crubit_rust_test(
Devin Jeanpierrec503d332023-04-26 11:28:11 -070027 name = test_name,
28 **kwargs
29 )