-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI to check Mathlib imports: negative test
- Loading branch information
1 parent
b0ce14d
commit d36cd44
Showing
3 changed files
with
31 additions
and
0 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
1 change: 1 addition & 0 deletions
1
LeanCamCombi/Mathlib/Combinatorics/Additive/ApproximateSubgroup.lean
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import os | ||
|
||
def list_files_by_type_recursive(folder_path, file_extension): | ||
"""Recursively lists all files in a folder and subfolders with the specified file extension.""" | ||
matching_files = [] | ||
for root, _, files in os.walk(folder_path): | ||
matching_files.extend(os.path.join(root, f) for f in files if f.endswith(file_extension)) | ||
return matching_files | ||
|
||
folder = "LeanCamCombi/Mathlib" | ||
extension = ".lean" | ||
files = list_files_by_type_recursive(folder, extension) | ||
|
||
for file in files: | ||
code = None | ||
with open(file, "r") as reader: | ||
code = reader.read() | ||
lines = code.split("\n") | ||
header = [line for line in lines if line.lstrip().startswith("import")] | ||
|
||
for imp in header: | ||
imp_file = imp.lstrip()[len("import"):].strip() | ||
if (not imp_file.startswith("Mathlib.")) and \ | ||
(not imp_file.startswith("LeanCamCombi.Mathlib")): | ||
raise IOError("A file in LeanCamCombi.Mathlib imports a file not in Mathlib or LeanCamCombi.Mathlib") |