-
Notifications
You must be signed in to change notification settings - Fork 11
[beman-tidy] Implement LICENSE.APPROVED #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vickgoodman
merged 13 commits into
bemanproject:main
from
vickgoodman:beman-tidy-implement-LICENSE.APPROVED
Jul 18, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
aa24c86
[beman-tidy] Added check and tests for LICENSE.APPROVED
vickgoodman 4221823
[beman-tidy] Run linter
vickgoodman 5c9a9e6
Merge branch 'main' of https://github.com/vickgoodman/infra into bema…
vickgoodman d6b1ce5
[beman-tidy] Updated check and tests for LICENSE.APPROVED
vickgoodman 2bd3185
[beman-tidy] Run linter
vickgoodman d68144f
[beman-tidy] Run linter
vickgoodman 4d2e0d4
[beman-tidy ] Refactored LICENSE.APPROVED check updated tests
vickgoodman 13236ab
[beman-tidy] Run linter
vickgoodman 15d92eb
[beman-tidy] Removed dead code
vickgoodman 0b808d9
[beman-tidy] Prettier regex with textwrap
a9975c6
Merge pull request #2 from neatudarius/pretty-regex
vickgoodman 50e4123
[beman-tidy] Clearer regex comment
vickgoodman 12d6985
[beman-tidy] Clearer comments for regex
vickgoodman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Empty file.
16 changes: 16 additions & 0 deletions
16
tools/beman-tidy/tests/lib/checks/beman_standard/license/conftest.py
This file contains hidden or 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,16 @@ | ||
| #!/usr/bin/env python3 | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| import pytest | ||
|
|
||
| from tests.utils.conftest import mock_repo_info, mock_beman_standard_check_config # noqa: F401 | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def repo_info(mock_repo_info): # noqa: F811 | ||
| return mock_repo_info | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def beman_standard_check_config(mock_beman_standard_check_config): # noqa: F811 | ||
| return mock_beman_standard_check_config |
14 changes: 14 additions & 0 deletions
14
tools/beman-tidy/tests/lib/checks/beman_standard/license/data/invalid/invalid-LICENSE-v1
This file contains hidden or 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,14 @@ | ||
| # Dummy LICENSE lines. | ||
| # beman-tidy does not actually check the content between the header and the footer. | ||
|
|
||
| ============================================================================== | ||
| Software from third parties included in the Beman Project: | ||
| ============================================================================== | ||
| The Beman Project contains third party software which is under different license | ||
| terms. All such code will be identified clearly using at least one of two | ||
| mechanisms: | ||
| 1) It will be in a separate directory tree with its own `LICENSE.txt` or | ||
| `LICENSE` file at the top containing the specific license and restrictions | ||
| which apply to that software, or | ||
| 2) It will contain specific license and restriction terms at the top of every | ||
| file. |
6 changes: 6 additions & 0 deletions
6
tools/beman-tidy/tests/lib/checks/beman_standard/license/data/invalid/invalid-LICENSE-v2
This file contains hidden or 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,6 @@ | ||
| ============================================================================== | ||
| The Beman Project is under the Apache License v2.0 with LLVM Exceptions: | ||
| ============================================================================== | ||
|
|
||
| # Dummy LICENSE lines. | ||
| # beman-tidy does not actually check the content between the header and the footer. |
15 changes: 15 additions & 0 deletions
15
tools/beman-tidy/tests/lib/checks/beman_standard/license/data/invalid/invalid-LICENSE-v3
This file contains hidden or 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,15 @@ | ||
| ============================================================================== | ||
| The Beman Project is under the Apache License v2.0 with LLVM Exceptions: | ||
| ============================================================================== | ||
|
|
||
| ============================================================================== | ||
| Software from third parties included in the Beman Project: | ||
| ============================================================================== | ||
| The Beman Project contains third party software which is under different license | ||
| terms. All such code will be identified clearly using at least one of two | ||
| mechanisms: | ||
| 1) It will be in a separate directory tree with its own `LICENSE.txt` or | ||
| `LICENSE` file at the top containing the specific license and restrictions | ||
| which apply to that software, or | ||
| 2) It will contain specific license and restriction terms at the top of every | ||
| file. |
18 changes: 18 additions & 0 deletions
18
tools/beman-tidy/tests/lib/checks/beman_standard/license/data/invalid/invalid-LICENSE-v4
This file contains hidden or 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,18 @@ | ||
| ============================================================================== | ||
| The "Extra" Beman Project is under the Apache License v2.0 with LLVM Exceptions: | ||
| ============================================================================== | ||
|
|
||
| # Dummy LICENSE lines. | ||
| # beman-tidy does not actually check the content between the header and the footer. | ||
|
|
||
| ============================================================================== | ||
| Software from third parties included in the Beman Project: | ||
| ============================================================================== | ||
| The Beman Project contains third party software which is under different license | ||
| terms. All such code will be identified clearly using at least one of two | ||
| mechanisms: | ||
| 1) It will be in a separate directory tree with its own `LICENSE.txt` or | ||
| `LICENSE` file at the top containing the specific license and restrictions | ||
| which apply to that software, or | ||
| 2) It will contain specific license and restriction terms at the top of every | ||
| file. |
18 changes: 18 additions & 0 deletions
18
tools/beman-tidy/tests/lib/checks/beman_standard/license/data/invalid/invalid-LICENSE-v5
This file contains hidden or 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,18 @@ | ||
| ============================================================================== | ||
| The Beman Project is under the Apache License v2.0 with LLVM Exceptions: | ||
| ============================================================================== | ||
|
|
||
| # Dummy LICENSE lines. | ||
| # beman-tidy does not actually check the content between the header and the footer. | ||
|
|
||
| ============================================================================== | ||
| "Extra" Software from third parties included in the Beman Project: | ||
| ============================================================================== | ||
| The Beman Project contains third party software which is under different license | ||
| terms. All such code will be identified clearly using at least one of two | ||
| mechanisms: | ||
| 1) It will be in a separate directory tree with its own `LICENSE.txt` or | ||
| `LICENSE` file at the top containing the specific license and restrictions | ||
| which apply to that software, or | ||
| 2) It will contain specific license and restriction terms at the top of every | ||
| file. |
18 changes: 18 additions & 0 deletions
18
tools/beman-tidy/tests/lib/checks/beman_standard/license/data/valid/valid-LICENSE-v1
This file contains hidden or 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,18 @@ | ||
| ============================================================================== | ||
| The Beman Project is under the Apache License v2.0 with LLVM Exceptions: | ||
| ============================================================================== | ||
|
|
||
| # Dummy LICENSE lines. | ||
| # beman-tidy does not actually check the content between the header and the footer. | ||
|
|
||
| ============================================================================== | ||
| Software from third parties included in the Beman Project: | ||
| ============================================================================== | ||
| The Beman Project contains third party software which is under different license | ||
| terms. All such code will be identified clearly using at least one of two | ||
| mechanisms: | ||
| 1) It will be in a separate directory tree with its own `LICENSE.txt` or | ||
| `LICENSE` file at the top containing the specific license and restrictions | ||
| which apply to that software, or | ||
| 2) It will contain specific license and restriction terms at the top of every | ||
| file. |
18 changes: 18 additions & 0 deletions
18
tools/beman-tidy/tests/lib/checks/beman_standard/license/data/valid/valid-LICENSE-v2
This file contains hidden or 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,18 @@ | ||
| ============================================================================== | ||
| The Beman Project is under the Boost Software License 1.0: | ||
| ============================================================================== | ||
|
|
||
| # Dummy LICENSE lines. | ||
| # beman-tidy does not actually check the content between the header and the footer. | ||
|
|
||
| ============================================================================== | ||
| Software from third parties included in the Beman Project: | ||
| ============================================================================== | ||
| The Beman Project contains third party software which is under different license | ||
| terms. All such code will be identified clearly using at least one of two | ||
| mechanisms: | ||
| 1) It will be in a separate directory tree with its own `LICENSE.txt` or | ||
| `LICENSE` file at the top containing the specific license and restrictions | ||
| which apply to that software, or | ||
| 2) It will contain specific license and restriction terms at the top of every | ||
| file. |
18 changes: 18 additions & 0 deletions
18
tools/beman-tidy/tests/lib/checks/beman_standard/license/data/valid/valid-LICENSE-v3
This file contains hidden or 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,18 @@ | ||
| ============================================================================== | ||
| The Beman Project is under the MIT License: | ||
| ============================================================================== | ||
|
|
||
| # Dummy LICENSE lines. | ||
| # beman-tidy does not actually check the content between the header and the footer. | ||
|
|
||
| ============================================================================== | ||
| Software from third parties included in the Beman Project: | ||
| ============================================================================== | ||
| The Beman Project contains third party software which is under different license | ||
| terms. All such code will be identified clearly using at least one of two | ||
| mechanisms: | ||
| 1) It will be in a separate directory tree with its own `LICENSE.txt` or | ||
| `LICENSE` file at the top containing the specific license and restrictions | ||
| which apply to that software, or | ||
| 2) It will contain specific license and restriction terms at the top of every | ||
| file. |
71 changes: 71 additions & 0 deletions
71
tools/beman-tidy/tests/lib/checks/beman_standard/license/test_license.py
This file contains hidden or 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,71 @@ | ||
| #!/usr/bin/env python3 | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| import pytest | ||
| from pathlib import Path | ||
|
|
||
| from tests.utils.path_runners import ( | ||
| run_check_for_each_path, | ||
| ) | ||
|
|
||
| # Actual tested checks. | ||
| from beman_tidy.lib.checks.beman_standard.license import ( | ||
| LicenseApprovedCheck, | ||
| ) | ||
|
|
||
| test_data_prefix = "tests/lib/checks/beman_standard/license/data" | ||
| valid_prefix = f"{test_data_prefix}/valid" | ||
| invalid_prefix = f"{test_data_prefix}/invalid" | ||
|
|
||
|
|
||
| def test__LICENSE_APPROVED__valid(repo_info, beman_standard_check_config): | ||
| """ | ||
| Test that a valid LICENSE file passes the check. | ||
| """ | ||
| valid_license_paths = [ | ||
| # Apache License v2.0 with LLVM Exceptions | ||
| Path(f"{valid_prefix}/valid-LICENSE-v1"), | ||
| # Boost Software License 1.0 | ||
| Path(f"{valid_prefix}/valid-LICENSE-v2"), | ||
| # MIT License | ||
| Path(f"{valid_prefix}/valid-LICENSE-v3"), | ||
| ] | ||
|
|
||
| run_check_for_each_path( | ||
| True, | ||
| valid_license_paths, | ||
| LicenseApprovedCheck, | ||
| repo_info, | ||
| beman_standard_check_config, | ||
| ) | ||
|
|
||
|
|
||
| def test__LICENSE_APPROVED__invalid(repo_info, beman_standard_check_config): | ||
| """ | ||
| Test that an invalid LICENSE file fails the check. | ||
| """ | ||
| invalid_license_paths = [ | ||
| # Almost valid LICENSE, but without header | ||
| Path(f"{invalid_prefix}/invalid-LICENSE-v1"), | ||
| # Almost valid LICENSE, but without footer | ||
| Path(f"{invalid_prefix}/invalid-LICENSE-v2"), | ||
| # Almost valid LICENSE, but not content between header and footer | ||
| Path(f"{invalid_prefix}/invalid-LICENSE-v3"), | ||
| # Almost valid LICENSE, but not exact header | ||
| Path(f"{invalid_prefix}/invalid-LICENSE-v4"), | ||
| # Almost valid LICENSE, but not exact footer | ||
| Path(f"{invalid_prefix}/invalid-LICENSE-v5"), | ||
| ] | ||
|
|
||
| run_check_for_each_path( | ||
| False, | ||
| invalid_license_paths, | ||
| LicenseApprovedCheck, | ||
| repo_info, | ||
| beman_standard_check_config, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="NOT implemented") | ||
| def test__LICENSE_APPROVED__fix_inplace(repo_info, beman_standard_check_config): | ||
| pass |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.