Skip to content

Commit

Permalink
changed check for LicenceTag to Fail if tag and file are not same lic…
Browse files Browse the repository at this point in the history
…ense but both are SPDX

Signed-off-by: Anton Utz <[email protected]>
  • Loading branch information
ant-u committed Mar 12, 2024
1 parent 89f05d9 commit 065ff46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/ros_license_toolkit/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ def _check_licenses(self, package: Package) -> None:
f"License text file '{license_text_file}' is " +\
f"of license {actual_license} but tag is " +\
f"{license_tag.get_license_id()}."
self.missing_license_texts_status[license_tag] = Status.WARNING
# If Tag and File both are in SPDX but don't match -> Error
if is_license_name_in_spdx_list(license_tag.get_license_id()):
self.missing_license_texts_status[license_tag] =\
Status.FAILURE
else:
self.missing_license_texts_status[license_tag] =\
Status.WARNING
self.files_with_wrong_tags[license_tag] = \
{'actual_license': actual_license,
'license_tag': license_tag.get_license_id()}
Expand Down
7 changes: 3 additions & 4 deletions test/systemtest/test_separate_pkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ def test_pkg_with_multiple_licenses_one_referenced_incorrect(self):

def test_pkg_wrong_license_file(self):
"""Test on a package with a license text file that does not match
the license declared in the package.xml."""
process, stdout = open_subprocess("test_pkg_wrong_license_file")
self.assertEqual(os.EX_OK, process.returncode)
self.assertIn(b"WARNING", stdout)
the license declared in the package.xml, both tag and file in spdx"""
self.assertEqual(os.EX_DATAERR, main(
["test/_test_data/test_pkg_wrong_license_file"]))


def open_subprocess(test_data_name: str):
Expand Down

0 comments on commit 065ff46

Please sign in to comment.