Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
beckermr committed Nov 25, 2024
1 parent 104667d commit 19035d2
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
19 changes: 19 additions & 0 deletions news/5555-skip-bad-specs-while-still-parsing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Fixed a bug where bad match specs from intermediate parsing results would cause parsing to fail. (#5555)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
53 changes: 53 additions & 0 deletions tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,56 @@ def test_parse_until_resolved_skip_avoids_undefined_jinja(
pytest.fail(
"Undefined variable caused error, even though this build is skipped"
)


@pytest.mark.parametrize("have_variant", [True, False])
def test_parse_until_resolved_missing_jinja_in_spec(
testing_metadata: MetaData,
tmp_path: Path,
have_variant: bool,
) -> None:
(recipe := tmp_path / (name := "meta.yaml")).write_text(
"""
package:
name: dummy
version: 1.0.0
build:
noarch: python
number: 0
requirements:
host:
- python ={{ python_min }}
run:
- python >={{ python_min }}
"""
)
(tmp_path / "conda_build_config.yaml").write_text(
"""
python_min:
- 3.6
"""
)
testing_metadata._meta_path = recipe
testing_metadata._meta_name = name
if have_variant:
testing_metadata.config.variant = {"python_min": "3.6"}
else:
delattr(testing_metadata.config, "variant")
delattr(testing_metadata.config, "variant_config_files")
delattr(testing_metadata.config, "variants")

try:
testing_metadata.parse_until_resolved()
if not have_variant:
pytest.fail("Undefined variable did NOT cause spec parsing error!")
else:
print("parsed OK!")
except (Exception, SystemExit):
if have_variant:
pytest.fail(
"Undefined variable caused spec parsing error even if we have the variant!"
)
else:
print("did not parse OK!")

0 comments on commit 19035d2

Please sign in to comment.