Skip to content

Commit a45c3f9

Browse files
committed
Fail tests when example scripts exit non-zero
1 parent 2d15730 commit a45c3f9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/test_diffusion.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ def setUp(self):
4848
print(f"Running commands in {self.out_f}, two steps of diffusion, deterministic=True")
4949

5050
self.results = {}
51+
self.exec_status = {}
5152

5253
for bash_file in sorted( glob.glob(f"{self.out_f}/*.sh"), reverse=False):
5354
test_name = os.path.basename(bash_file)[:-len('.sh')]
5455
res, output = execute(f"Running {test_name}", f'bash {bash_file}', return_='tuple', add_message_and_command_line_to_output=True)
56+
self.exec_status[test_name] = (exit_code, output)
5557

5658
self.results[test_name] = dict(
5759
state = 'failed' if res else 'passed',
@@ -61,6 +63,13 @@ def setUp(self):
6163
#subprocess.run(["bash", bash_file], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
6264
#subprocess.run(["bash", bash_file])
6365

66+
def test_examples_run_without_errors(self):
67+
for name, (exit_code, output) in sorted(self.exec_status.items()):
68+
with self.subTest(example=name):
69+
self.assertEqual(exit_code, 0,
70+
msg=f"Example '{name}' exited with {exit_code}\n{output}")
71+
72+
6473

6574
def test_commands(self):
6675
"""

0 commit comments

Comments
 (0)