Skip to content

Commit

Permalink
Replace sys.exit call in tests_failed()
Browse files Browse the repository at this point in the history
  • Loading branch information
beeankha committed Jun 11, 2024
1 parent 45be77d commit 3c9516f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions conda_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3553,7 +3553,12 @@ def test(
return True


def tests_failed(package_or_metadata, move_broken, broken_dir, config):
def tests_failed(
package_or_metadata: str | os.PathLike | Path | MetaData,
move_broken: bool,
broken_dir: str | os.PathLike | Path,
config: Config,
) -> None:
"""
Causes conda to exit if any of the given package's tests failed.
Expand Down Expand Up @@ -3581,7 +3586,7 @@ def tests_failed(package_or_metadata, move_broken, broken_dir, config):
_delegated_update_index(
os.path.dirname(os.path.dirname(pkg)), verbose=config.debug, threads=1
)
sys.exit("TESTS FAILED: " + os.path.basename(pkg))
raise CondaBuildUserError("TESTS FAILED: " + os.path.basename(pkg))


@deprecated(
Expand Down
10 changes: 10 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,13 @@ def test_wsl_unsupported(
env={},
stats={},
)


def test_tests_failed(testing_metadata: MetaData, tmp_path: Path):
with pytest.raises(CondaBuildUserError):
build.tests_failed(
package_or_metadata=testing_metadata,
move_broken=True,
broken_dir=tmp_path,
config=testing_metadata.config,
)

0 comments on commit 3c9516f

Please sign in to comment.