From 3937b8b122568ad48a78db054b2edf735315611d Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Thu, 3 Sep 2026 19:09:40 +0100 Subject: [PATCH 1/4] FIX: return non-zero when pass listing fails --- olive/cli/run_pass.py | 1 + 1 file changed, 1 insertion(+) diff --git a/olive/cli/run_pass.py b/olive/cli/run_pass.py index 3ed269185f..18f2076b5b 100644 --- a/olive/cli/run_pass.py +++ b/olive/cli/run_pass.py @@ -198,6 +198,7 @@ def _list_passes(self): except Exception as e: print(f"Error loading pass configurations: {e}") print("Unable to list available passes.") + raise SystemExit(1) from e # Template configuration for the one command From 42cfbf9185c0b4ac1e1b541a0258b98570dad5c3 Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Thu, 3 Sep 2026 19:10:21 +0100 Subject: [PATCH 2/4] TST: cover run-pass list failure exit status --- test/cli/test_run_pass_exit_status.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 test/cli/test_run_pass_exit_status.py diff --git a/test/cli/test_run_pass_exit_status.py b/test/cli/test_run_pass_exit_status.py new file mode 100644 index 0000000000..df8d73b590 --- /dev/null +++ b/test/cli/test_run_pass_exit_status.py @@ -0,0 +1,24 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +# -------------------------------------------------------------------------- +from argparse import ArgumentParser +from unittest.mock import patch + +import pytest + +from olive.cli.run_pass import RunPassCommand + + +def test_list_passes_failure_exits_nonzero(): + parser = ArgumentParser() + sub_parsers = parser.add_subparsers() + RunPassCommand.register_subcommand(sub_parsers) + args = parser.parse_args(["run-pass", "--list-passes"]) + command = RunPassCommand(parser, args) + + with patch("olive.package_config.OlivePackageConfig.load_default_config", side_effect=RuntimeError("broken config")): + with pytest.raises(SystemExit) as exc_info: + command._list_passes() + + assert exc_info.value.code == 1 From dc3becb887cb893cae29cd22d53b8b1231aad581 Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Thu, 10 Sep 2026 16:21:09 +0100 Subject: [PATCH 3/4] Test list-pass failure through the public command entrypoint --- test/cli/test_run_pass_exit_status.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/test_run_pass_exit_status.py b/test/cli/test_run_pass_exit_status.py index df8d73b590..116f07edde 100644 --- a/test/cli/test_run_pass_exit_status.py +++ b/test/cli/test_run_pass_exit_status.py @@ -19,6 +19,6 @@ def test_list_passes_failure_exits_nonzero(): with patch("olive.package_config.OlivePackageConfig.load_default_config", side_effect=RuntimeError("broken config")): with pytest.raises(SystemExit) as exc_info: - command._list_passes() + command.run() assert exc_info.value.code == 1 From 4a0508ba7b660d7fd777bc5b518147c962031a19 Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Thu, 10 Sep 2026 16:51:29 +0100 Subject: [PATCH 4/4] Keep public-entrypoint regression consistent with lint rules --- test/cli/test_run_pass_exit_status.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/cli/test_run_pass_exit_status.py b/test/cli/test_run_pass_exit_status.py index 116f07edde..7cb7c5167a 100644 --- a/test/cli/test_run_pass_exit_status.py +++ b/test/cli/test_run_pass_exit_status.py @@ -17,8 +17,10 @@ def test_list_passes_failure_exits_nonzero(): args = parser.parse_args(["run-pass", "--list-passes"]) command = RunPassCommand(parser, args) - with patch("olive.package_config.OlivePackageConfig.load_default_config", side_effect=RuntimeError("broken config")): - with pytest.raises(SystemExit) as exc_info: - command.run() + config_error = patch( + "olive.package_config.OlivePackageConfig.load_default_config", side_effect=RuntimeError("broken config") + ) + with config_error, pytest.raises(SystemExit) as exc_info: + command.run() assert exc_info.value.code == 1