tests: add test for FIXME boilerplate to package_sanity (#9285)
* package_sanity: add test_no_fixme * cleanup & better assert message
This commit is contained in:
parent
718be8a645
commit
72fa122101
1 changed files with 25 additions and 0 deletions
|
@ -59,3 +59,28 @@ def test_package_version_consistency():
|
||||||
spack.fetch_strategy.check_pkg_attributes(pkg)
|
spack.fetch_strategy.check_pkg_attributes(pkg)
|
||||||
for version in pkg.versions:
|
for version in pkg.versions:
|
||||||
assert spack.fetch_strategy.for_package_version(pkg, version)
|
assert spack.fetch_strategy.for_package_version(pkg, version)
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_fixme():
|
||||||
|
"""Packages should not contain any boilerplate such as
|
||||||
|
FIXME or example.com."""
|
||||||
|
errors = []
|
||||||
|
fixme_regexes = [
|
||||||
|
r'remove this boilerplate',
|
||||||
|
r'FIXME: Put',
|
||||||
|
r'FIXME: Add',
|
||||||
|
r'example.com',
|
||||||
|
]
|
||||||
|
for name in spack.repo.all_package_names():
|
||||||
|
repo = spack.repo.Repo(spack.paths.packages_path)
|
||||||
|
filename = repo.filename_for_package_name(name)
|
||||||
|
with open(filename, 'r') as package_file:
|
||||||
|
for i, line in enumerate(package_file):
|
||||||
|
pattern = next((r for r in fixme_regexes
|
||||||
|
if re.search(r, line)), None)
|
||||||
|
if pattern:
|
||||||
|
errors.append(
|
||||||
|
"%s:%d: boilerplate needs to be removed: %s" %
|
||||||
|
(filename, i, line.strip())
|
||||||
|
)
|
||||||
|
assert [] == errors
|
||||||
|
|
Loading…
Reference in a new issue