-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows GitHub to parse it and display annotations on pull requests.
- Loading branch information
Showing
4 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
- Added `--github` output option for `lint`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# SPDX-FileCopyrightText: 2019 Free Software Foundation Europe e.V. <https://fsfe.org> | ||
# SPDX-FileCopyrightText: 2022 Florian Snow <[email protected]> | ||
# SPDX-FileCopyrightText: 2024 Nico Rikken <[email protected]> | ||
# SPDX-FileCopyrightText: 2024 Michal Čihař <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
|
@@ -11,7 +12,7 @@ | |
|
||
from conftest import cpython, posix | ||
|
||
from reuse.lint import format_lines, format_plain | ||
from reuse.lint import format_github, format_lines, format_plain | ||
from reuse.project import Project | ||
from reuse.report import ProjectReport | ||
|
||
|
@@ -271,4 +272,45 @@ def test_lint_lines_read_errors(fake_repository): | |
assert "read error" in result | ||
|
||
|
||
def test_lint_github_output(fake_repository): | ||
"""Complete test for lint with github output.""" | ||
# Prepare a repository that includes all types of situations: | ||
# missing_licenses, unused_licenses, bad_licenses, deprecated_licenses, | ||
# licenses_without_extension, files_without_copyright, | ||
# files_without_licenses, read_errors | ||
(fake_repository / "invalid-license.py").write_text( | ||
"SPDX-License-Identifier: invalid" | ||
) | ||
(fake_repository / "no-license.py").write_text( | ||
"SPDX-FileCopyrightText: Jane Doe" | ||
) | ||
(fake_repository / "LICENSES" / "invalid-license-text").write_text( | ||
"An invalid license text" | ||
) | ||
(fake_repository / "LICENSES" / "Nokia-Qt-exception-1.1.txt").write_text( | ||
"Deprecated" | ||
) | ||
(fake_repository / "LICENSES" / "MIT").write_text("foo") | ||
(fake_repository / "file with spaces.py").write_text("foo") | ||
|
||
project = Project.from_directory(fake_repository) | ||
report = ProjectReport.generate(project) | ||
|
||
lines_result = format_github(report) | ||
lines_result_lines = lines_result.splitlines() | ||
|
||
assert len(lines_result_lines) == 12 | ||
|
||
for line in lines_result_lines: | ||
assert re.match("::error file=.+::[^:]+", line) | ||
|
||
assert lines_result.count("invalid-license.py") == 3 | ||
assert lines_result.count("no-license.py") == 1 | ||
assert lines_result.count("LICENSES") == 6 | ||
assert lines_result.count("invalid-license-text") == 3 | ||
assert lines_result.count("Nokia-Qt-exception-1.1.txt") == 2 | ||
assert lines_result.count("MIT") == 2 | ||
assert lines_result.count("file with spaces.py") == 2 | ||
|
||
|
||
# REUSE-IgnoreEnd |