ww: unify directory package-test products
This commit is contained in:
@@ -2869,7 +2869,8 @@ check_init(Checker *c, Arena *a)
|
||||
c->is_test = 0; /* #15: caller (w6c main) sets it after init */
|
||||
c->is_test_package = 0;
|
||||
c->test_module = "test";
|
||||
c->test_target = NULL;
|
||||
c->test_targets = NULL;
|
||||
c->n_test_targets = 0;
|
||||
typesinit(a);
|
||||
c->top = newscope(a, NULL);
|
||||
c->cur = c->top;
|
||||
@@ -3995,6 +3996,15 @@ check_import_usage_and_collisions(Checker *c, Node *file)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
check_test_target(const Checker *c, const char *path)
|
||||
{
|
||||
if (path == NULL) return 0;
|
||||
for (int i = 0; i < c->n_test_targets; i++)
|
||||
if (strcmp(c->test_targets[i], path) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
check_file(Checker *c, Node *file)
|
||||
{
|
||||
@@ -4018,8 +4028,7 @@ check_file(Checker *c, Node *file)
|
||||
&& !u->imported && u->sourceid == file->sourceid
|
||||
&& u->usepath
|
||||
&& (strcmp(u->usepath, c->test_module) == 0
|
||||
|| (c->test_target != NULL
|
||||
&& strcmp(u->usepath, c->test_target) == 0)))
|
||||
|| check_test_target(c, u->usepath)))
|
||||
u->used = 1;
|
||||
if (u->kind == N_USE && !u->imported
|
||||
&& u->sourceid == file->sourceid
|
||||
@@ -4383,9 +4392,8 @@ check_file(Checker *c, Node *file)
|
||||
* package as `main`: that would collide with its own entry.
|
||||
* This is a compiler-owned binding, never source alias syntax;
|
||||
* use the canonical target path as its private qualifier. */
|
||||
if (c->test_target != NULL
|
||||
&& strcmp(d->module, c->test_target) == 0)
|
||||
alias = c->test_target;
|
||||
if (check_test_target(c, d->module))
|
||||
alias = d->module;
|
||||
id = newnode(c->a, N_DOT, fp);
|
||||
id->lhs = newnode(c->a, N_IDENT, fp);
|
||||
id->lhs->str = alias;
|
||||
|
||||
@@ -613,8 +613,8 @@ struct Checker {
|
||||
* bodies and export compiler-private metadata,
|
||||
* but do not synthesize an entry. */
|
||||
const char *test_module; /* generated dispatcher support qualifier */
|
||||
const char *test_target; /* canonical target path used only as the
|
||||
* compiler-owned generated-main qualifier */
|
||||
const char **test_targets; /* canonical generated-main target paths */
|
||||
int n_test_targets;
|
||||
int sep_mode; /* -c package compilation: imported interfaces are
|
||||
* present, so absent members are hard export errors. */
|
||||
Node *synth_test_run; /* exact compiler-generated support.run DOT;
|
||||
|
||||
Reference in New Issue
Block a user