Skip to content

Commit

Permalink
chore: Add REUSE linter to check license and copyright information
Browse files Browse the repository at this point in the history
The linter is skipped if not available or if running on TravisCI.
  • Loading branch information
buhtz authored Dec 31, 2024
1 parent 7f96e5e commit 460a414
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions common/test/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
PYLINT_AVAILABLE = shutil.which('pylint') is not None
RUFF_AVAILABLE = shutil.which('ruff') is not None
FLAKE8_AVAILABLE = shutil.which('flake8') is not None
REUSE_AVAILABLE = shutil.which('reuse') is not None

ANY_LINTER_AVAILABLE = any((
PYLINT_AVAILABLE,
Expand Down Expand Up @@ -356,3 +357,28 @@ def test050_pylint_exclusive_ruleset(self):

# any other errors?
self.assertEqual(r.stderr, '')

@unittest.skipUnless(REUSE_AVAILABLE, BASE_REASON.format('REUSE'))
def test060_reuse(self):
"""The reuse linter check license and copyright information in the
repository.
The info need to be complete and available for all files. The
info need to be provided as meta data conforming the SPDX standard.
"""
proc = subprocess.run(
['reuse', 'lint', '--lines'],
check=False,
universal_newlines=True,
capture_output=True
)

error_n = len(proc.stdout.splitlines())
if error_n > 0:
print(proc.stdout)

self.assertEqual(
0, error_n, f'REUSE linter found {error_n} problem(s).')

# any other errors?
self.assertEqual(proc.stderr, '')

0 comments on commit 460a414

Please sign in to comment.