documentation_tests.txt - sort filenames alphabetically (#24647)
* Sort filenames alphabetically * Add check for order
This commit is contained in:
@@ -24,12 +24,16 @@ REPO_PATH = "."
|
||||
if __name__ == "__main__":
|
||||
doctest_file_path = os.path.join(REPO_PATH, "utils/documentation_tests.txt")
|
||||
non_existent_paths = []
|
||||
all_paths = []
|
||||
with open(doctest_file_path) as fp:
|
||||
for line in fp:
|
||||
line = line.strip()
|
||||
path = os.path.join(REPO_PATH, line)
|
||||
if not (os.path.isfile(path) or os.path.isdir(path)):
|
||||
non_existent_paths.append(line)
|
||||
all_paths.append(path)
|
||||
if len(non_existent_paths) > 0:
|
||||
non_existent_paths = "\n".join(non_existent_paths)
|
||||
raise ValueError(f"`utils/documentation_tests.txt` contains non-existent paths:\n{non_existent_paths}")
|
||||
if all_paths != sorted(all_paths):
|
||||
raise ValueError("Files in `utils/documentation_tests.txt` are not in alphabetical order.")
|
||||
|
||||
Reference in New Issue
Block a user