Skip to content

Commit

Permalink
Windows path
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre committed Jun 29, 2021
1 parent c3901e2 commit ad4abc8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 38 deletions.
59 changes: 22 additions & 37 deletions test/current_toolchain_tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
# Test that all toolchain tools are executable targets
[
sh_test(
name = tool + "_test",
srcs = ["current_exec_files_test.sh"],
args = [
"$(rootpath //rust/toolchain:current_exec_{}_files)".format(tool),
"--executable",
# The final arg is expected to match a similar pattern:
# cargo 1.53.0 (4369396ce 2021-04-27)
r"^" + tool + r" [0-9\.]\+ ([0-9a-z]\{9\} [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})",
],
data = [
"//rust/toolchain:current_exec_{}_files".format(tool),
],
)
for tool in [
"cargo",
"clippy",
"rustc",
"rustdoc",
"rustfmt",
]
]

# Note, rustc_srcs is too big for this test
# Executable targets will output a pattern similar to the following
# cargo 1.53.0 (4369396ce 2021-04-27)
# Also Note, rustc_srcs is too big for this test
_FILES = {
"rust_stdlib": r"\.rlib",
"rustc_lib": r"libstd",
"cargo": ("--executable", r"^cargo [0-9\.]\+ ([0-9a-z]\{9\} [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
"clippy": ("--executable", r"^clippy [0-9\.]\+ ([0-9a-z]\{8\} [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
"rust_stdlib": ("--files", r"\.rlib"),
"rustc": ("--executable", r"^rustc [0-9\.]\+ ([0-9a-z]\{9\} [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
"rustc_lib": ("--files", r"rustc_driver"),
"rustdoc": ("--executable", r"^rustdoc [0-9\.]\+ ([0-9a-z]\{9\} [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
"rustfmt": ("--executable", r"^rustfmt [0-9\.]\+\-stable ([0-9a-z]\{8\} [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\})"),
}

# Generate a list manifest for all files in the filegroup
Expand All @@ -37,22 +19,25 @@ _FILES = {
outs = ["{}_manifest".format(files)],
cmd = "for file in $(rootpaths //rust/toolchain:current_exec_{}_files); do echo $$file >> $@; done".format(files),
)
for files in _FILES.keys()
for files in _FILES
if "--files" in _FILES[files]
]

# Check to see that a particular file patter exists in the manifest
# Test that all toolchain tools are executable targets
[
sh_test(
name = "{}_test".format(files),
name = tool + "_test",
srcs = ["current_exec_files_test.sh"],
args = [
"$(rootpath :{}_manifest)".format(files),
"--files",
pattern,
"$(rootpath //rust/toolchain:current_exec_{}_files)".format(tool) if "--executable" == arg else "$(rootpath {}_manifest)".format(tool),
arg,
"'{}'".format(pattern),
],
data = [
":{}_manifest".format(files),
],
"//rust/toolchain:current_exec_{}_files".format(tool),
] + (
["{}_manifest".format(tool)] if "--files" == arg else []
),
)
for files, pattern in _FILES.items()
for tool, (arg, pattern) in _FILES.items()
]
7 changes: 6 additions & 1 deletion test/current_toolchain_tools/current_exec_files_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ set -xeuo pipefail

TARGET="$1"
OPTION="$2"
PATTERN="$3"

# To parse this argument on windows it must be wrapped in quotes but
# these quotes should not be passed to grep. Remove them here.
PATTERN="$(echo -n "$3" | sed "s/'//g")"

if [[ "${OPTION}" == "--executable" ]]; then
# Clippy requires this environment variable is set
export SYSROOT=""

"${TARGET}" --version
"${TARGET}" --version | grep "${PATTERN}"
exit 0
fi

if [[ "${OPTION}" == "--files" ]]; then
cat "${TARGET}"
grep "${PATTERN}" "${TARGET}"
exit 0
fi
Expand Down

0 comments on commit ad4abc8

Please sign in to comment.