ww: preserve command package identities

This commit is contained in:
2026-08-13 03:37:08 +09:00
parent 10d24a3237
commit 4377634bb9
10 changed files with 348 additions and 43 deletions

View File

@@ -1575,7 +1575,12 @@ parsefile(Parser *p)
&& strcmp(p->testmodule, "__wwtest") == 0
&& strcmp(active, "__wwtest") == 0
&& strcmp(name, "test") == 0;
if (strcmp(name, last) != 0 && !testsupport) {
int commandpackage = p->commandpackage
&& p->pathmod == NULL && p->resetmod != NULL
&& (strcmp(name, "main") == 0
|| strcmp(name, "main_test") == 0);
if (strcmp(name, last) != 0 && !testsupport
&& !commandpackage) {
errorf(p->cur.pos,
"package %s does not match import path %s",
name, active);

View File

@@ -381,6 +381,8 @@ struct Parser {
* component) instead of overwriting curmod. */
const char *testmodule; /* hidden package-driver alias for toolchain
* `package test`; NULL outside that compile */
int commandpackage; /* selected command family: package main/main_test
* validates kind without replacing resetmod identity */
};
void parserinit(Parser*, Arena*, Lex*);