test(pipeline): give the package cross/register scope cases a cross-walk call

The cross and register scope-failure cases defined S and called s.m()
inside pkg/__init__.py. The per-file LSP already resolves those calls,
and the parallel driver skips the cross-file walk for a file whose call
sites are all resolved, so CBM_TEST_PY_LSP_SCOPE_FAIL_STAGE=cross and
=register never fired on the parallel path and both parallel cases saw
no file error.

For those two stages, move S into memo_def.py (imported by
pkg/__init__.py) so run() holds calls only the cross walk resolves, and
count that module's File node. The raw stage keeps its single-file
fixture; the error assertions are unchanged.

With the corrected fixture all eight package-scope pipeline cases pass;
removing the CBM_PY_LSP_SCOPE_ERROR capture in pass_parallel.c turns
exactly the two parallel cross/register cases RED again.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This commit is contained in:
Martin Vogel committed 2026-10-12 21:58:25 +02:00
1 parent 7effa3cc59
commit 2bdb5efc44
1 file changed
+16 -4
+16 -4
View File
@@ -10962,13 +10962,24 @@ static int python_init_scope_pipeline_case(bool parallel, const char *failure_st
FAIL("failed to create Python package fixture");
n = snprintf(path, sizeof(path), "%s/pkg", root);
bool written = n > 0 && (size_t)n < sizeof(path);
/* The cross and register stages run inside the cross-file walk, which the
* parallel driver skips for a file whose call sites the per-file LSP
* already resolved: those stages need a call only the cross walk resolves. */
bool cross_walk_stage = failure_stage && (strcmp(failure_stage, "cross") == 0 ||
strcmp(failure_stage, "register") == 0);
if (written) {
cbm_mkdir_p(path, 0755);
written = python_module_write_fixture_file(
root, "pkg/__init__.py",
failure_stage ? "class S:\n def m(self):\n return 1\n"
"def run():\n s = S()\n return s.m()\n"
: body);
cross_walk_stage ? "from memo_def import S\n"
"def run():\n s = S()\n return s.m()\n"
: failure_stage ? "class S:\n def m(self):\n return 1\n"
"def run():\n s = S()\n return s.m()\n"
: body);
}
if (written && cross_walk_stage) {
written = python_module_write_fixture_file(root, "memo_def.py",
"class S:\n def m(self):\n return 1\n");
}
if (written && !failure_stage) {
written = python_module_write_fixture_file(root, "plain.py", body) &&
@@ -11033,7 +11044,8 @@ static int python_init_scope_pipeline_case(bool parallel, const char *failure_st
correct = project &&
cbm_store_find_nodes_by_label(store, project, "File", &files, &file_count) ==
CBM_STORE_OK &&
file_count == (failure_stage ? 1 : 5) + (parallel ? 52 : 0);
file_count ==
(cross_walk_stage ? 2 : failure_stage ? 1 : 5) + (parallel ? 52 : 0);
cbm_store_free_nodes(files, file_count);
if (project && !failure_stage) {
const char *modules[] = {"plain", "pkg"};