Skip to content

Commit f43c53d

Browse files
committed
checkstyle: batch mdformat into single invocation
test_markdown_style was spawning a bash+diff+mdformat subprocess for each of the 66 markdown files individually (23s). Pass all files to mdformat --check in one call (~4s). Signed-off-by: Riccardo Mancini <mancio@amazon.com>
1 parent 5f7cbbd commit f43c53d

1 file changed

Lines changed: 4 additions & 15 deletions

File tree

tests/integration_tests/style/test_markdown.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,15 @@ def test_markdown_style():
1111
"""
1212
Test that markdown files adhere to the style rules.
1313
"""
14-
# Get all *.md files from the project
1514
md_files = list(utils_repo.git_repo_files(root="..", glob="*.md"))
16-
17-
# Assert if somehow no markdown files were found.
1815
assert len(md_files) != 0
1916

20-
needs_format = False
21-
22-
# Run commands
23-
for md_file in md_files:
24-
rc, output, _ = utils.run_cmd(
25-
f"bash -c 'diff -u --color {md_file} <(mdformat - < {md_file})'",
26-
)
27-
if rc != 0:
28-
print(output)
29-
needs_format = True
17+
file_args = " ".join(str(f) for f in md_files)
18+
rc, output, _ = utils.run_cmd(f"mdformat --check {file_args}")
3019

3120
assert (
32-
not needs_format
33-
), "Some markdown files need formatting. Either run `./tools/devtool sh mdformat .` in the repository root, or apply the above diffs manually."
21+
rc == 0
22+
), f"Some markdown files need formatting. Either run `./tools/devtool sh mdformat .` in the repository root, or apply the diffs manually.\n{output}"
3423

3524

3625
def test_markdown_internal_links():

0 commit comments

Comments
 (0)