Skip to content

Commit

Permalink
Add a test for matcher decorators with multiprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
kiri11 committed Sep 4, 2024
1 parent da175a9 commit 4d3a3fd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions libcst/codemod/tests/test_codemod_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,34 @@ def baz() -> str:
"- 3 warnings were generated.",
output.stderr,
)

def test_matcher_decorators_multiprocessing(self) -> None:
file_count = 5
code = """
def baz(): # type: int
return 5
"""
with tempfile.TemporaryDirectory() as tmpdir:
p = Path(tmpdir)
# Using more than chunksize=4 files to trigger multiprocessing
for i in range(file_count):
(p / f"mod{i}.py").write_text(CodemodTest.make_fixture_data(code))
output = subprocess.run(
[
sys.executable,
"-m",
"libcst.tool",
"codemod",
# Good candidate since it uses matcher decorators
"convert_type_comments.ConvertTypeComments",
str(p),
"--jobs",
str(file_count),
],
encoding="utf-8",
stderr=subprocess.PIPE,
)
self.assertIn(
f"Transformed {file_count} files successfully.",
output.stderr,
)

0 comments on commit 4d3a3fd

Please sign in to comment.