|
| 1 | +load(":current_toolchain_files_test.bzl", "current_toolchain_files_test") |
| 2 | + |
| 3 | +exports_files([ |
| 4 | + "current_toolchain_files_test.sh", |
| 5 | +]) |
| 6 | + |
1 | 7 | # Executable targets will output a pattern similar to the following
|
2 | 8 | # cargo 1.53.0 (4369396ce 2021-04-27)
|
3 | 9 | # Also Note, rustc_srcs is too big for this test
|
4 | 10 | _FILES = {
|
5 |
| - "cargo": ("--executable", r"^cargo [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
6 |
| - "clippy": ("--executable", r"^clippy [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
7 |
| - "rust_stdlib": ("--files", r"\.rlib"), |
8 |
| - "rustc": ("--executable", r"^rustc [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
9 |
| - "rustc_lib": ("--files", r"rustc_driver"), |
10 |
| - "rustdoc": ("--executable", r"^rustdoc [0-9\.]\+ ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
11 |
| - "rustfmt": ("--executable", r"^rustfmt [0-9\.]\+\-stable ([0-9a-z]\+ [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"), |
| 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\})"), |
12 | 18 | }
|
13 | 19 |
|
14 |
| -# Generate a list manifest for all files in the filegroup |
15 |
| -[ |
16 |
| - genrule( |
17 |
| - name = "{}_manifest_genrule".format(files), |
18 |
| - srcs = ["//rust/toolchain:current_{}_files".format(files)], |
19 |
| - outs = ["{}_manifest".format(files)], |
20 |
| - cmd = "for file in $(rootpaths //rust/toolchain:current_{}_files); do echo $$file >> $@; done".format(files), |
21 |
| - ) |
22 |
| - for files in _FILES |
23 |
| - if "--files" in _FILES[files] |
24 |
| -] |
25 |
| - |
26 |
| -# Test that all toolchain tools are executable targets |
| 20 | +# Test that all toolchain tools consumable (executables are executable and filegroups contain expected sources) |
27 | 21 | [
|
28 |
| - sh_test( |
| 22 | + current_toolchain_files_test( |
29 | 23 | name = tool + "_test",
|
30 |
| - srcs = ["current_exec_files_test.sh"], |
31 |
| - args = [ |
32 |
| - "$(rootpath //rust/toolchain:current_{}_files)".format(tool) if "--executable" == arg else "$(rootpath {}_manifest)".format(tool), |
33 |
| - arg, |
34 |
| - "'{}'".format(pattern), |
35 |
| - ], |
36 |
| - data = [ |
37 |
| - "//rust/toolchain:current_{}_files".format(tool), |
38 |
| - ] + ( |
39 |
| - ["{}_manifest".format(tool)] if "--files" == arg else [] |
40 |
| - ), |
| 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), |
41 | 34 | )
|
42 |
| - for tool, (arg, pattern) in _FILES.items() |
| 35 | + for tool, (kind, pattern) in _FILES.items() |
43 | 36 | ]
|
0 commit comments