From 60db3df24ba6680b4b155614870cf3c203a71fe6 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Fri, 7 Jun 2024 11:45:41 -0700 Subject: [PATCH] Remove glob_sh_run (#4041) file_test's --dump_output flag has essentially supplanted this functionality, and is necessary for execution on multi-file tests. --- bazel/sh_run/BUILD | 5 ----- bazel/sh_run/exec.sh | 16 ---------------- bazel/sh_run/rules.bzl | 35 ----------------------------------- explorer/BUILD | 18 ------------------ toolchain/check/BUILD | 25 ------------------------- toolchain/lex/BUILD | 24 ------------------------ toolchain/lower/BUILD | 24 ------------------------ toolchain/parse/BUILD | 24 ------------------------ 8 files changed, 171 deletions(-) delete mode 100644 bazel/sh_run/BUILD delete mode 100755 bazel/sh_run/exec.sh delete mode 100644 bazel/sh_run/rules.bzl diff --git a/bazel/sh_run/BUILD b/bazel/sh_run/BUILD deleted file mode 100644 index e58b9bb2cddc..000000000000 --- a/bazel/sh_run/BUILD +++ /dev/null @@ -1,5 +0,0 @@ -# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -# Exceptions. See /LICENSE for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -exports_files(["exec.sh"]) diff --git a/bazel/sh_run/exec.sh b/bazel/sh_run/exec.sh deleted file mode 100755 index ad0d904bf020..000000000000 --- a/bazel/sh_run/exec.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -# -# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -# Exceptions. See /LICENSE for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Turn any pwd-relative files into absolute paths. Other args may be -# BUILD_WORKING_DIRECTORY-relative, which will be handled by the executed -# binary. -ARGS=("$@") -for i in "${!ARGS[@]}"; do - if [[ -e "${ARGS[$i]}" ]]; then - ARGS[$i]="$(realpath ${ARGS[$i]})" - fi -done -exec "${ARGS[@]}" diff --git a/bazel/sh_run/rules.bzl b/bazel/sh_run/rules.bzl deleted file mode 100644 index 9fddf31da4db..000000000000 --- a/bazel/sh_run/rules.bzl +++ /dev/null @@ -1,35 +0,0 @@ -# Part of the Carbon Language project, under the Apache License v2.0 with LLVM -# Exceptions. See /LICENSE for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -"""Rules for building fuzz tests.""" - -load("//bazel/cc_toolchains:defs.bzl", "cc_env") - -def sh_run(name, args, **kwargs): - """Produces a target which can run with the given args.""" - - native.sh_binary( - name = name, - srcs = ["//bazel/sh_run:exec.sh"], - tags = ["manual"], - args = args, - **kwargs - ) - -def glob_sh_run(file_exts, args, data, run_ext = "run", **kwargs): - """Produces a per-file sh_run.""" - files = native.glob( - ["**"], - exclude_directories = 1, - ) - for f in files: - if f.split(".")[-1] not in file_exts: - continue - sh_run( - name = "%s.%s" % (f, run_ext), - args = args + ["$(location %s)" % f], - data = data + [f], - env = cc_env(), - **kwargs - ) diff --git a/explorer/BUILD b/explorer/BUILD index 0a4a832a5980..89aced90f742 100644 --- a/explorer/BUILD +++ b/explorer/BUILD @@ -4,7 +4,6 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") load("//bazel/cc_toolchains:defs.bzl", "cc_env") -load("//bazel/sh_run:rules.bzl", "glob_sh_run") load("//testing/file_test:rules.bzl", "file_test") package(default_visibility = [ @@ -95,23 +94,6 @@ file_test( ), ) -glob_sh_run( - args = ["$(location //explorer)"], - data = ["//explorer"], - file_exts = ["carbon"], -) - -glob_sh_run( - args = [ - "$(location //explorer)", - "--parser_debug", - "--trace_file=-", - ], - data = ["//explorer"], - file_exts = ["carbon"], - run_ext = "verbose", -) - filegroup( name = "carbon_files", srcs = glob(["testdata/**/*.carbon"]), diff --git a/toolchain/check/BUILD b/toolchain/check/BUILD index 4ea908128dca..f61c2e0c4613 100644 --- a/toolchain/check/BUILD +++ b/toolchain/check/BUILD @@ -3,7 +3,6 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@rules_cc//cc:defs.bzl", "cc_library") -load("//bazel/sh_run:rules.bzl", "glob_sh_run") load("//testing/fuzzing:rules.bzl", "cc_fuzz_test") package(default_visibility = ["//visibility:public"]) @@ -284,27 +283,3 @@ cc_library( "@llvm-project//llvm:Support", ], ) - -glob_sh_run( - args = [ - "$(location //toolchain/driver:carbon)", - "compile", - "--phase=check", - "--dump-sem-ir", - "--dump-raw-sem-ir", - ], - data = ["//toolchain/driver:carbon"], - file_exts = ["carbon"], -) - -glob_sh_run( - args = [ - "$(location //toolchain/driver:carbon)", - "-v", - "compile", - "--phase=check", - ], - data = ["//toolchain/driver:carbon"], - file_exts = ["carbon"], - run_ext = "verbose", -) diff --git a/toolchain/lex/BUILD b/toolchain/lex/BUILD index 3b144b8b5f35..ee4bc4e09f2a 100644 --- a/toolchain/lex/BUILD +++ b/toolchain/lex/BUILD @@ -3,7 +3,6 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") -load("//bazel/sh_run:rules.bzl", "glob_sh_run") load("//testing/fuzzing:rules.bzl", "cc_fuzz_test") package(default_visibility = ["//visibility:public"]) @@ -297,26 +296,3 @@ cc_binary( "@llvm-project//llvm:Support", ], ) - -glob_sh_run( - args = [ - "$(location //toolchain/driver:carbon)", - "compile", - "--phase=lex", - "--dump-tokens", - ], - data = ["//toolchain/driver:carbon"], - file_exts = ["carbon"], -) - -glob_sh_run( - args = [ - "$(location //toolchain/driver:carbon)", - "-v", - "compile", - "--phase=lex", - ], - data = ["//toolchain/driver:carbon"], - file_exts = ["carbon"], - run_ext = "verbose", -) diff --git a/toolchain/lower/BUILD b/toolchain/lower/BUILD index c057fa608011..da6e85214409 100644 --- a/toolchain/lower/BUILD +++ b/toolchain/lower/BUILD @@ -3,7 +3,6 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@rules_cc//cc:defs.bzl", "cc_library") -load("//bazel/sh_run:rules.bzl", "glob_sh_run") package(default_visibility = ["//visibility:public"]) @@ -54,26 +53,3 @@ cc_library( "@llvm-project//llvm:Support", ], ) - -glob_sh_run( - args = [ - "$(location //toolchain/driver:carbon)", - "compile", - "--phase=lower", - "--dump-llvm-ir", - ], - data = ["//toolchain/driver:carbon"], - file_exts = ["carbon"], -) - -glob_sh_run( - args = [ - "$(location //toolchain/driver:carbon)", - "-v", - "compile", - "--phase=lower", - ], - data = ["//toolchain/driver:carbon"], - file_exts = ["carbon"], - run_ext = "verbose", -) diff --git a/toolchain/parse/BUILD b/toolchain/parse/BUILD index 93cbddadccfb..449d291dfc33 100644 --- a/toolchain/parse/BUILD +++ b/toolchain/parse/BUILD @@ -3,7 +3,6 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") -load("//bazel/sh_run:rules.bzl", "glob_sh_run") load("//testing/fuzzing:rules.bzl", "cc_fuzz_test") package(default_visibility = ["//visibility:public"]) @@ -191,26 +190,3 @@ cc_test( "@googletest//:gtest", ], ) - -glob_sh_run( - args = [ - "$(location //toolchain/driver:carbon)", - "compile", - "--phase=parse", - "--dump-parse-tree", - ], - data = ["//toolchain/driver:carbon"], - file_exts = ["carbon"], -) - -glob_sh_run( - args = [ - "$(location //toolchain/driver:carbon)", - "-v", - "compile", - "--phase=parse", - ], - data = ["//toolchain/driver:carbon"], - file_exts = ["carbon"], - run_ext = "verbose", -)