Skip to content

Commit 0b31278

Browse files
committed
harden against h5dump missing
1 parent adc26a0 commit 0b31278

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

toolchain/mfc/test/test.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ def test():
213213
# pylint: disable=too-many-locals, too-many-branches, too-many-statements, trailing-whitespace
214214
def _process_silo_file(silo_filepath: str, case: TestCase, out_filepath: str):
215215
"""Process a single silo file with h5dump and check for NaNs/Infinities."""
216+
# Check that silo file exists before attempting to process it
217+
if not os.path.exists(silo_filepath):
218+
raise MFCException(
219+
f"Test {case}: Expected silo file missing: {silo_filepath}. "
220+
f"Check the post-process log at: {out_filepath}"
221+
)
222+
216223
h5dump = f"{HDF5.get_install_dirpath(case.to_input_file())}/bin/h5dump"
217224

218225
if not os.path.exists(h5dump or ""):
@@ -224,7 +231,8 @@ def _process_silo_file(silo_filepath: str, case: TestCase, out_filepath: str):
224231

225232
if err != 0:
226233
raise MFCException(
227-
f"Test {case}: Failed to run h5dump. You can find the run's output in {out_filepath}, "
234+
f"Test {case}: Failed to run h5dump on {silo_filepath}. "
235+
f"You can find the run's output in {out_filepath}, "
228236
f"and the case dictionary in {case.get_filepath()}."
229237
)
230238

@@ -322,6 +330,14 @@ def _handle_case(case: TestCase, devices: typing.Set[int]):
322330
out_filepath = os.path.join(case.get_dirpath(), "out_post.txt")
323331
common.file_write(out_filepath, cmd.stdout)
324332

333+
# Check return code from post-process run
334+
if cmd.returncode != 0:
335+
cons.print(cmd.stdout)
336+
raise MFCException(
337+
f"Test {case}: Failed to execute MFC (post-process). "
338+
f"See log at: {out_filepath}"
339+
)
340+
325341
silo_dir = os.path.join(case.get_dirpath(), 'silo_hdf5', 'p0')
326342
if os.path.isdir(silo_dir):
327343
for silo_filename in os.listdir(silo_dir):

0 commit comments

Comments
 (0)