Skip to content
Draft
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
39 changes: 32 additions & 7 deletions bioconda_utils/lint/check_completeness.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

import os
from . import LintCheck, ERROR, WARNING, INFO
from . import LintCheck, ERROR, WARNING, INFO, _recipe


class missing_build_number(LintCheck):
Expand Down Expand Up @@ -81,19 +81,44 @@ class missing_tests(LintCheck):
and/or any file named ``run_test.py`, ``run_test.sh`` or
``run_test.pl`` executing tests.

You can either add the test section on the top level of
your meta.yaml file; or if you use an ``outputs:`` section
to specify multiple outputs, add a test to each of your
``outputs:`` entries.
"""
test_files = ['run_test.py', 'run_test.sh', 'run_test.pl']

def check_recipe(self, recipe):
if any(os.path.exists(os.path.join(recipe.dir, f))
for f in self.test_files):
for f in self.test_files):
return
if recipe.get('test/commands', '') or recipe.get('test/imports', ''):
return
if recipe.get('test', False) is not False:
self.message(section='test')
# if multiple `outputs:` are specified, we check that
# all subpackages have `test:` specified, but ignore
# top-level tests, as top-level package outputs will
# become incompatible with multiple `outputs:` in the
# future, see:
# https://conda.org/learn/ceps/cep-0014/#outputs-section
if recipe.get('outputs', ''):
packages = recipe.get('outputs')
else:
self.message()
packages = [ recipe, ]
# can't use the Recipe.get function, as we might have plain dicts
# here; so we need to go one level of the resulting dicts at
# a time and check that all of them have a test specified
tests_specified = [
t.get('commands', '') or t.get('imports', '')
for t in [ p.get('test', {}) for p in packages ]
]
if all(tests_specified):
return
for i in range(len(packages)):
if not tests_specified[i]:
if not isinstance(packages[i], _recipe.Recipe) and packages[i].get(f'outputs/{i}/test', ''):
self.message(section=f'outputs/{i}/test')
elif packages[i].get('test', ''):
self.message(section='test')
else:
self.message()


class missing_hash(LintCheck):
Expand Down
14 changes: 12 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,23 @@ def recipe_dir(recipes_folder: py.path.local, tmpdir: py.path.local,
for remove in utils.ensure_list(case['remove']):
path = remove.split('/')
cont = recipe
select_by_name = False
for p in path[:-1]:
cont = cont[p]
if select_by_name:
for subpackage in cont:
if subpackage['name'] == p:
cont = subpackage
select_by_name = False
else:
cont = cont.get(p, {})
if p == "outputs":
select_by_name = True
if isinstance(cont, list):
for n in range(len(cont)):
del cont[n][path[-1]]
else:
del cont[path[-1]]
if cont.get(path[-1], ""):
del cont[path[-1]]
if 'add' in case:
dict_merge(recipe, case['add'])

Expand Down
65 changes: 62 additions & 3 deletions test/lint_cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,56 @@ setup:
license: BSD
home: https://elsewhere
summary: the_summary
meta:
folder: meta_package
meta.yaml:
package:
name: meta_package
version: 0.1
source:
- url: https://somewhere
sha256: 123
- url: https://elsewhere
sha256: abc
build:
noarch: True
number: 0
run_exports:
# add a run export
# (note that jinja templating as in reality is not
# supported by our test system to the same
# extend as in conda build)
- "{{ pin_subpackage('meta_package') }}"
outputs:
- name: meta_one
build:
noarch: True
run_exports:
# add a run export
# (note that jinja templating as in reality is not
# supported by our test system to the same
# extend as in conda build)
- "{{ pin_subpackage('meta_one') }}"
test:
commands:
- do nothing
- name: meta_two
build:
noarch: True
number: 0
run_exports:
# add a run export
# (note that jinja templating as in reality is not
# supported by our test system to the same
# extend as in conda build)
- "{{ pin_subpackage('meta_two') }}"
test:
imports:
- no imports to see here
about:
license: MIT
home: https://elsewhere
summary: another_summary
repodata:
bioconda:
one:
Expand All @@ -60,6 +110,8 @@ setup:
- version: 0.0.1
four:
- version: 0.0.1
meta_package:
- version: 0.0.1
conda-forge:
three:
- version: 1.0
Expand Down Expand Up @@ -123,11 +175,14 @@ tests:
add: { about: { license: "" } }
expect: missing_license
- name: missing_tests
remove: test
remove:
- test
- outputs/meta_one/test
expect: missing_tests
- name: missing_tests_empty_section
remove:
- test/commands
- outputs/meta_two/test/imports
expect: missing_tests
- name: missing_tests_but_runtest_py
remove: test
Expand All @@ -142,7 +197,10 @@ tests:
add_files:
run_test.pl: ""
- name: missing_tests_but_runtst_sh
remove: test
remove:
- test
- outputs/meta_one/test
- outputs/meta_two/test
add_files:
run_tst.sh: ""
expect: missing_tests
Expand Down Expand Up @@ -369,7 +427,7 @@ tests:
add: { package: { version: "v0.1" } }
- name: in_other_channels
expect: in_other_channels
repodata: { conda-forge: { one: [{ version: 0.1 }], two: [version: 0.1] } }
repodata: { conda-forge: { one: [{ version: 0.1 }], two: [version: 0.1], meta_package: [version: 0.1] } }
- name: long_summary
expect: long_summary
add:
Expand All @@ -383,6 +441,7 @@ tests:
blacklist: |
recipes/one
recipes/two
recipes/meta_package
config:
blacklists:
- blacklist
Expand Down