Skip to content

Commit

Permalink
extend test_run_shell_cmd_with_hooks to check that run_shell_cmd pre …
Browse files Browse the repository at this point in the history
…hook is triggered sufficiently early
  • Loading branch information
boegel committed Jun 5, 2024
1 parent 41a3ce7 commit aa7cb7c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/framework/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,32 @@ def post_run_shell_cmd_hook(cmd, *args, **kwargs):
])
self.assertEqual(stdout, expected_stdout)

# also check in dry run mode, to verify that pre-run_shell_cmd hook is triggered sufficiently early
update_build_option('extended_dry_run', True)

with self.mocked_stdout_stderr():
run_shell_cmd("make")
stdout = self.get_stdout()

expected_stdout = '\n'.join([
"pre-run hook 'make' in %s" % cwd,
' running shell command "echo make"',
' (in %s)' % cwd,
'',
])
self.assertEqual(stdout, expected_stdout)

# also check with trace output enabled
update_build_option('extended_dry_run', False)
update_build_option('trace', True)

with self.mocked_stdout_stderr():
run_shell_cmd("make")
stdout = self.get_stdout()

regex = re.compile('>> running shell command:\n\techo make', re.M)
self.assertTrue(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout))


def suite():
""" returns all the testcases in this module """
Expand Down

0 comments on commit aa7cb7c

Please sign in to comment.