Skip to content

Commit

Permalink
make CI green
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde committed Aug 16, 2023
1 parent d991218 commit a86c438
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/ansible_builder/_target_scripts/introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,9 @@ def sanitize_requirements(collection_py_reqs):
consolidated.append(req)
seen_pkgs.add(req.name)
except Exception as e:
logger.error('Failed to parse requirements from %s, error: %s', collection, e)
sys.exit(1)
msg = f'Failed to parse requirements from {collection}, error: {e}'
logger.error(msg)
sys.exit(msg)

# removal of unwanted packages
sanitized = []
Expand Down
2 changes: 2 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def pytest_sessionfinish(session, exitstatus):
# If we are the main worker thread, we've been called last, so do the cleanup.
if worker_id is None:
for runtime in CONTAINER_RUNTIMES:
if runtime not in FOUND_RUNTIMES:
continue
data_file = pathlib.Path(base_tmpfile + runtime)
if data_file.exists():
for image_name in data_file.read_text().split("\n"):
Expand Down
18 changes: 11 additions & 7 deletions test/unit/test_requirements.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from ansible_builder._target_scripts.introspect import sanitize_requirements


Expand Down Expand Up @@ -27,13 +29,15 @@ def test_remove_unwanted_requirements():
]


def test_skip_bad_formats():
"""A single incorrectly formatted requirement should warn, but not block other reqs"""
assert sanitize_requirements({'foo.bar': [
'foo',
'bar'
], 'foo.bad': ['zizzer zazzer zuzz'] # not okay
}) == ['foo # from collection foo.bar', 'bar # from collection foo.bar']
def test_skip_bad_formats(capsys):
"""A single incorrectly formatted requirement should raise error"""

with pytest.raises(SystemExit) as exc_info:
sanitize_requirements({
'foo.bar': ['foo', 'bar'],
'foo.bad': ['zizzer zazzer zuzz'] # not okay
})
assert exc_info.value.code.startswith('Failed to parse requirements')


def test_sanitize_requirements_do_not_exclude():
Expand Down

0 comments on commit a86c438

Please sign in to comment.