diff --git a/bin/run-util b/bin/run-util index 4a192ae7f1327b02aeb306e8b95779c820e1e24f_YmluL3J1bi11dGls..52997affe73611155ca5eecc715595eba6786e81_YmluL3J1bi11dGls 100755 --- a/bin/run-util +++ b/bin/run-util @@ -18,6 +18,11 @@ def __init__(self, benchmark_data): self._benchmark_data = benchmark_data - self.base_command = benchmark_data['simple-command']['command'] + + def get_var(key): + key = f'simple-command.{key}' + return poulpe.get_one_value(benchmark_data, key) + + self.base_command = get_var('command') self.command = None @@ -22,3 +27,6 @@ self.command = None + self.cwd = get_var('cwd') + + def apply_data_env(self, data_env_data): @@ -24,8 +32,8 @@ def apply_data_env(self, data_env_data): - variables_data = self._benchmark_data['simple-command']['variables'] + variables_data = self._benchmark_data['simple-command'].get('variables') def get_var(key): full_key = f'bench-input-vars.{key}' return poulpe.get_one_value(data_env_data, full_key) variables = {} @@ -26,15 +34,16 @@ def get_var(key): full_key = f'bench-input-vars.{key}' return poulpe.get_one_value(data_env_data, full_key) variables = {} - for name, value in variables_data.items(): - if value.startswith('DATA-VARS:'): - key = value.split(':', 1)[1] - value = get_var(key) - assert value is not None - variables[name] = value + if variables_data is not None: + for name, value in variables_data.items(): + if value.startswith('DATA-VARS:'): + key = value.split(':', 1)[1] + value = get_var(key) + assert value is not None + variables[name] = value self.command = self.base_command.format(**variables) @@ -38,6 +47,10 @@ self.command = self.base_command.format(**variables) + if self.cwd.startswith('DATA-VARS:'): + key = self.cwd.split(':', 1)[1] + self.cwd = get_var(key) + def run_one(bin_env_path, data_env_path, benchmark, result): result_data = {} @@ -62,7 +75,7 @@ cmd = SimpleCommand(benchmark_data) cmd.apply_data_env(data_env_data) - r = _time_command(bin_env_path, data_env_path, cmd.command) + r = _time_command(bin_env_path, data_env_path, cmd) # we should store more result_data['result'] = {} @@ -82,6 +95,5 @@ time_cmd = [ shell_path, "hyperfine", - cmd, "--export-json", tmp_result.name, @@ -86,5 +98,6 @@ "--export-json", tmp_result.name, - "--ignore-failure", + "--", + cmd.command, ] @@ -89,4 +102,8 @@ ] + cwd = data_env_path + if cmd.cwd is not None: + cwd = os.path.join(cwd, cmd.cwd) + subprocess.check_call( time_cmd, @@ -91,6 +108,6 @@ subprocess.check_call( time_cmd, - cwd=data_env_path, + cwd=cwd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) diff --git a/tests/test-simple-run.t b/tests/test-simple-run.t index 4a192ae7f1327b02aeb306e8b95779c820e1e24f_dGVzdHMvdGVzdC1zaW1wbGUtcnVuLnQ=..52997affe73611155ca5eecc715595eba6786e81_dGVzdHMvdGVzdC1zaW1wbGUtcnVuLnQ= 100644 --- a/tests/test-simple-run.t +++ b/tests/test-simple-run.t @@ -75,6 +75,7 @@ $ env-desc set black-tiny-bad.pbd meta.method simple-command $ env-desc set black-tiny-bad.pbd simple-command.command "black --check {file}" $ env-desc set black-tiny-bad.pbd simple-command.variables.file DATA-VARS:black.check.tiny.bad + $ env-desc set black-tiny-bad.pbd simple-command.cwd DATA-VARS:. $ env-desc show black-tiny-bad.pbd meta: @@ -83,6 +84,7 @@ name = black.check.tiny simple-command: command = black --check {file} + cwd = DATA-VARS:. variables: file = DATA-VARS:black.check.tiny.bad @@ -119,6 +121,7 @@ name = black.check.tiny simple-command: command = black --check {file} + cwd = DATA-VARS:. variables: file = DATA-VARS:black.check.tiny.good