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 8193af6
Show file tree
Hide file tree
Showing 4 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
2 changes: 1 addition & 1 deletion test/unit/test_introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ def test_parse_args_default_action():
def test_corrupt_python_requirements():
with pytest.raises(SystemExit) as excinfo:
sanitize_requirements({'test.metadata': ['invalid_package=1']})
assert excinfo.value.code == 1
assert excinfo.value.code.startswith('Failed to parse requirements from')
16 changes: 10 additions & 6 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 @@ -28,12 +30,14 @@ 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']
"""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 8193af6

Please sign in to comment.