From 9b23dd5ce0b84a6b841456332ae23f77171dc7b5 Mon Sep 17 00:00:00 2001 From: vindard <17693119+vindard@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:04:58 -0400 Subject: [PATCH] refactor: remove 'abspath' usage --- toolchains/workspace-pnpm/macros.bzl | 8 +++----- toolchains/workspace-pnpm/run_in_dir.py | 17 ++++++----------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/toolchains/workspace-pnpm/macros.bzl b/toolchains/workspace-pnpm/macros.bzl index a333c0725a..34b46d9bb1 100644 --- a/toolchains/workspace-pnpm/macros.bzl +++ b/toolchains/workspace-pnpm/macros.bzl @@ -574,17 +574,15 @@ def _npm_test_impl( pnpm_toolchain = ctx.attrs._workspace_pnpm_toolchain[WorkspacePnpmToolchainInfo] - exec_cmd = cmd_args(program_run_info, format = "{}::abspath") - run_cmd_args = cmd_args([ ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter, pnpm_toolchain.run_in_dir[DefaultInfo].default_outputs, "--cwd", cmd_args([build_context.workspace_root, ctx.label.package], delimiter = "/"), - "--", - exec_cmd, + "--bin", + cmd_args(program_run_info), + program_args, ]) - run_cmd_args.add(program_args) args_file = ctx.actions.write("args.txt", run_cmd_args) diff --git a/toolchains/workspace-pnpm/run_in_dir.py b/toolchains/workspace-pnpm/run_in_dir.py index 4c6ce60ee9..2dbb146e70 100644 --- a/toolchains/workspace-pnpm/run_in_dir.py +++ b/toolchains/workspace-pnpm/run_in_dir.py @@ -20,6 +20,10 @@ def compute_path(arg: str) -> str: "--cwd", help="Directory under which to run the program", ) + parser.add_argument( + "--bin", + help="Binary to execute program with", + ) parser.add_argument( "args", help="Program and arguments", @@ -27,17 +31,8 @@ def compute_path(arg: str) -> str: ) args = parser.parse_args() - args.args.pop(0) # pops the '--' separator off - - cwd = args.cwd - - cmd = [] - for arg in args.args: - cmd.append(compute_path(arg)) + cmd = [os.path.abspath(args.bin), *args.args] - exit_code = subprocess.call(cmd, cwd=cwd) + exit_code = subprocess.call(cmd, cwd=args.cwd) sys.exit(exit_code) - - -