Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions olive/cli/run_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions test/cli/test_run_pass_exit_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -------------------------------------------------------------------------
# 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)

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