diff --git a/testsuite/drivers/alr.py b/testsuite/drivers/alr.py index 8ae2fe38e..856a328b2 100644 --- a/testsuite/drivers/alr.py +++ b/testsuite/drivers/alr.py @@ -493,7 +493,7 @@ def alr_with(dep="", path="", url="", commit="", branch="", return run_alr(*args, force=force) -def add_action(type, command, name="", directory=""): +def add_action(type: str, command: [str], name="", directory=""): """ Add an action to the manifest in the current directory. :param str type: "pre-build", etc diff --git a/testsuite/drivers/asserts.py b/testsuite/drivers/asserts.py index a62f1d5b3..2cc332349 100644 --- a/testsuite/drivers/asserts.py +++ b/testsuite/drivers/asserts.py @@ -134,3 +134,11 @@ def match_deploy_dir(crate : str, path_fragment : str): assert_match(f".*[: ]{crate.upper()}_ALIRE_PREFIX=[^\\n]*" f"{re.escape(path_fragment)}[^\\n]*{crate}_.*", p.out) + + +def assert_substring(target: str, text: str): + """ + Check that a string is contained in another string + """ + assert target in text, \ + f"Missing expected string '{target}' in text:\n{text}" \ No newline at end of file diff --git a/testsuite/tests/action/missing-exec/test.py b/testsuite/tests/action/missing-exec/test.py new file mode 100644 index 000000000..d467743e9 --- /dev/null +++ b/testsuite/tests/action/missing-exec/test.py @@ -0,0 +1,17 @@ +""" +Check that an action trying to run a missing executable reports such an error. +""" + +from drivers.alr import run_alr, add_action, init_local_crate +from drivers.asserts import assert_substring + +init_local_crate() + +add_action('pre-build', ['fake-missing-exec']) + +p = run_alr("build", complain_on_error=False) + +assert_substring("Command not found [fake-missing-exec]", + p.out) + +print('SUCCESS') diff --git a/testsuite/tests/action/missing-exec/test.yaml b/testsuite/tests/action/missing-exec/test.yaml new file mode 100644 index 000000000..00fb56e10 --- /dev/null +++ b/testsuite/tests/action/missing-exec/test.yaml @@ -0,0 +1,3 @@ +driver: python-script +build_mode: both +indexes: {} \ No newline at end of file