Skip to content

Commit 115ac31

Browse files
[mypyc] Improve comments and docstrings in tests (python#12223)
Tests for multi-file and separate compilation modes are a bit special, and it seems useful to have more documentation. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
1 parent a3fc35a commit 115ac31

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

mypyc/test-data/run-multimodule.test

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
-- These test cases compile two modules at a time (native and other.py)
1+
-- These test cases compile two or more modules at a time.
2+
-- Any file prefixed with "other" is compiled.
3+
--
4+
-- Note that these are run in three compilation modes: regular,
5+
-- multi-file and separate. See the docstrings of
6+
-- mypyc.test.test_run.TestRunMultiFile and
7+
-- mypyc.test.test_run.TestRunSeparate for more information.
8+
--
9+
-- Some of these files perform multiple incremental runs. See
10+
-- test-data/unit/check-incremental.test for more information
11+
-- about how this is specified (e.g. .2 file name suffixes).
212

313
[case testMultiModulePackage]
414
from p.other import g

mypyc/test/test_run.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class TestRun(MypycDataSuite):
127127
base_path = test_temp_dir
128128
optional_out = True
129129
multi_file = False
130-
separate = False
130+
separate = False # If True, using separate (incremental) compilation
131131

132132
def run_case(self, testcase: DataDrivenTestCase) -> None:
133133
# setup.py wants to be run from the root directory of the package, which we accommodate
@@ -347,7 +347,11 @@ def get_separate(self, program_text: str,
347347

348348

349349
class TestRunMultiFile(TestRun):
350-
"""Run the main multi-module tests in multi-file compilation mode."""
350+
"""Run the main multi-module tests in multi-file compilation mode.
351+
352+
In multi-file mode each module gets compiled into a separate C file,
353+
but all modules (C files) are compiled together.
354+
"""
351355

352356
multi_file = True
353357
test_name_suffix = '_multi'
@@ -358,7 +362,20 @@ class TestRunMultiFile(TestRun):
358362

359363

360364
class TestRunSeparate(TestRun):
361-
"""Run the main multi-module tests in separate compilation mode."""
365+
"""Run the main multi-module tests in separate compilation mode.
366+
367+
In this mode there are multiple compilation groups, which are compiled
368+
incrementally. Each group is compiled to a separate C file, and these C
369+
files are compiled separately.
370+
371+
Each compiled module is placed into a separate compilation group, unless
372+
overridden by a special comment. Consider this example:
373+
374+
# separate: [(["other.py", "other_b.py"], "stuff")]
375+
376+
This puts other.py and other_b.py into a compilation group named "stuff".
377+
Any files not mentioned in the comment will get single-file groups.
378+
"""
362379

363380
separate = True
364381
test_name_suffix = '_separate'

0 commit comments

Comments
 (0)