xref: /aosp_15_r20/external/bazelbuild-rules_rust/test/current_toolchain_files/BUILD.bazel (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1load(":current_toolchain_files_test.bzl", "current_toolchain_files_test")
2
3exports_files([
4    "current_toolchain_files_test.sh",
5])
6
7# Executable targets will output a pattern similar to the following
8# cargo 1.53.0 (4369396ce 2021-04-27)
9# Also Note, rustc_srcs is too big for this test
10_FILES = {
11    "cargo": ("executable", r"^cargo [0-9\.]\+\(-nightly\)\? ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
12    "clippy": ("executable", r"^clippy [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
13    "rust_stdlib": ("files", r"\.rlib"),
14    "rustc": ("executable", r"^rustc [0-9\.]\+\(-nightly\)\? ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
15    "rustc_lib": ("files", r"rustc_driver"),
16    "rustdoc": ("executable", r"^rustdoc [0-9\.]\+\(\-nightly\)\? ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
17    "rustfmt": ("executable", r"^rustfmt [0-9\.]\+\-\(stable\|nightly\) ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
18}
19
20# Test that all toolchain tools consumable (executables are executable and filegroups contain expected sources)
21[
22    current_toolchain_files_test(
23        name = tool + "_test",
24        kind = kind,
25        pattern = pattern,
26        # TOOO: Windows requires use of bash which is not guaranteed to be available.
27        # The test runner should ideally be rewritten in rust so that windows could
28        # be tested.
29        target_compatible_with = select({
30            "@platforms//os:windows": ["@platforms//:incompatible"],
31            "//conditions:default": [],
32        }),
33        tool = "//rust/toolchain:current_{}_files".format(tool),
34    )
35    for tool, (kind, pattern) in _FILES.items()
36]
37