Skip to content

Commit 16d6e7a

Browse files
authored
Add verbose option to run_tests.py (#529)
- add `--verbose` flag to scripts/run_tests.py to print executed commands - document `--verbose` and `--counts` usage in the CI guide
1 parent b5c189a commit 16d6e7a

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

docs/user_guide/ci.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,12 @@ Example usage:
5656
5757
Additional MPI arguments can be supplied with ``--additional-mpi-args`` when
5858
running in ``processes`` mode.
59+
60+
The ``--counts`` option allows sequential execution of tests with several
61+
thread/process counts. When specified, the script will iterate over the provided
62+
values, updating ``PPC_NUM_THREADS`` or ``PPC_NUM_PROC`` accordingly before each
63+
run.
64+
65+
Use ``--verbose`` to print every command executed by ``run_tests.py``. This can
66+
be helpful for debugging CI failures or verifying the exact arguments passed to
67+
the test binaries.

scripts/run_tests.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,23 @@ def init_cmd_args():
2828
type=int,
2929
help="List of process/thread counts to run sequentially"
3030
)
31+
parser.add_argument(
32+
"--verbose",
33+
action="store_true",
34+
help="Print commands executed by the script"
35+
)
3136
args = parser.parse_args()
3237
_args_dict = vars(args)
3338
return _args_dict
3439

3540

3641
class PPCRunner:
37-
def __init__(self):
42+
def __init__(self, verbose=False):
3843
self.__ppc_num_threads = None
3944
self.__ppc_num_proc = None
4045
self.__ppc_env = None
4146
self.work_dir = None
47+
self.verbose = verbose
4248

4349
self.valgrind_cmd = "valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all"
4450

@@ -71,6 +77,8 @@ def setup_env(self, ppc_env):
7177
self.work_dir = Path(self.__get_project_path()) / "build" / "bin"
7278

7379
def __run_exec(self, command):
80+
if self.verbose:
81+
print("Executing:", " ".join(shlex.quote(part) for part in command))
7482
result = subprocess.run(command, shell=False, env=self.__ppc_env)
7583
if result.returncode != 0:
7684
raise Exception(f"Subprocess return {result.returncode}.")
@@ -144,7 +152,7 @@ def run_performance(self):
144152

145153

146154
def _execute(args_dict, env):
147-
runner = PPCRunner()
155+
runner = PPCRunner(verbose=args_dict.get("verbose", False))
148156
runner.setup_env(env)
149157

150158
if args_dict["running_type"] in ["threads", "processes"]:

0 commit comments

Comments
 (0)