diff --git a/benchbuild/command.py b/benchbuild/command.py index a4dcddf85..17a1e09aa 100644 --- a/benchbuild/command.py +++ b/benchbuild/command.py @@ -580,6 +580,17 @@ def __call__(self, *args: tp.Any, **kwargs: tp.Any) -> tp.Any: cmd_w_output = self.as_plumbum(**kwargs) return watch(cmd_w_output)(*args) + def rendered_args(self, **kwargs: tp.Any) -> tp.Tuple[str, ...]: + args = [] + + for arg in self._args: + if isinstance(arg, ArgsToken): + args.extend(arg.render(**kwargs)) + else: + args.append(str(arg)) + + return tuple(args) + def as_plumbum(self, **kwargs: tp.Any) -> BoundEnvCommand: """ Convert this command into a plumbum compatible command. @@ -597,14 +608,7 @@ def as_plumbum(self, **kwargs: tp.Any) -> BoundEnvCommand: assert cmd_path.exists(), f"{str(cmd_path)} doesn't exist!" cmd = local[str(cmd_path)] - - args = [] - for arg in self._args: - if isinstance(arg, ArgsToken): - args.extend(arg.render(**kwargs)) - else: - args.append(str(arg)) - cmd_w_args = cmd[args] + cmd_w_args = cmd[self.rendered_args(**kwargs)] cmd_w_output = cmd_w_args if self.output: output_path = self.output.render(**kwargs)