ww: unify directory package-test products
This commit is contained in:
@@ -3,7 +3,7 @@ package wcc;
|
||||
import syntax;
|
||||
|
||||
export fn compilefile(file: *syntax.node, testmode: i32, testpackage: i32,
|
||||
testmodule: str, testtarget: str, sepmode: i32, wwifd: i32,
|
||||
testmodule: str, testtargets: []str, sepmode: i32, wwifd: i32,
|
||||
haswwi: i32,
|
||||
entrymode: i32, packageinitsymbol: str, initdispatchsymbol: str) i32 = {
|
||||
let tc: syntax.tctx;
|
||||
@@ -13,7 +13,7 @@ export fn compilefile(file: *syntax.node, testmode: i32, testpackage: i32,
|
||||
ck.istest = testmode;
|
||||
ck.istestpackage = testpackage;
|
||||
if (testmodule.len > 0) { ck.testmodule = testmodule; };
|
||||
ck.testtarget = testtarget;
|
||||
ck.testtargets = testtargets;
|
||||
ck.sepmode = sepmode;
|
||||
ck.packageinitsymbol = packageinitsymbol;
|
||||
checkfile(&ck, file);
|
||||
|
||||
@@ -23,8 +23,8 @@ type checker = struct {
|
||||
istestpackage: i32, // validate/retain package-owned @test bodies and
|
||||
// export compiler-private metadata; no entry synth
|
||||
testmodule: str, // generated dispatcher support qualifier
|
||||
testtarget: str, // canonical target path used only as the
|
||||
// compiler-owned generated-main qualifier
|
||||
testtargets: []str, // canonical generated-main target paths used only as
|
||||
// compiler-owned generated-main qualifiers
|
||||
sepmode: i32, // -c package compilation: imported interfaces are
|
||||
// present, so absent members are hard export errors.
|
||||
synthtestrun: *syntax.node, // exact generated support.run DOT; its
|
||||
@@ -8507,8 +8507,8 @@ fn checkinit(c: *checker, tc: *syntax.tctx) void = {
|
||||
c.istest = 0i32; // #15: caller (w6c main) sets it after init
|
||||
c.istestpackage = 0i32;
|
||||
c.testmodule = "test";
|
||||
let emptytesttarget: str;
|
||||
c.testtarget = emptytesttarget;
|
||||
let emptytesttargets: []str;
|
||||
c.testtargets = emptytesttargets;
|
||||
c.sepmode = 0i32; // caller (w6c main) sets it from -c
|
||||
c.synthtestrun = nil;
|
||||
c.verbose = 0;
|
||||
@@ -8524,6 +8524,15 @@ fn checkinit(c: *checker, tc: *syntax.tctx) void = {
|
||||
seedprimitives(c);
|
||||
};
|
||||
|
||||
fn checktesttarget(c: *checker, path: str) bool = {
|
||||
let i: i32 = 0;
|
||||
for (i < c.testtargets.len) {
|
||||
if (syntax.streq(c.testtargets[i], path)) { return true; };
|
||||
i += 1;
|
||||
};
|
||||
return false;
|
||||
};
|
||||
|
||||
fn checkfile(c: *checker, file: *syntax.node) void = {
|
||||
if (file == nil) { return; };
|
||||
if (file.kind != syntax.nkind.N_FILE) { return; };
|
||||
@@ -8547,8 +8556,7 @@ fn checkfile(c: *checker, file: *syntax.node) void = {
|
||||
if (su.kind == syntax.nkind.N_USE
|
||||
&& su.imported == 0 && su.sourceid == file.sourceid
|
||||
&& (syntax.streq(su.usepath, c.testmodule)
|
||||
|| (c.testtarget.len > 0
|
||||
&& syntax.streq(su.usepath, c.testtarget)))) {
|
||||
|| checktesttarget(c, su.usepath))) {
|
||||
su.used = 1i32;
|
||||
};
|
||||
if (su.kind == syntax.nkind.N_USE && su.imported == 0
|
||||
@@ -8719,9 +8727,8 @@ fn checkfile(c: *checker, file: *syntax.node) void = {
|
||||
if (t.imported != 0 && t.nmod.len > 0) {
|
||||
let alias: str = t.pkgname;
|
||||
if (alias.len == 0) { alias = t.nmod; };
|
||||
if (c.testtarget.len > 0
|
||||
&& syntax.streq(t.nmod, c.testtarget)) {
|
||||
alias = c.testtarget;
|
||||
if (checktesttarget(c, t.nmod)) {
|
||||
alias = t.nmod;
|
||||
};
|
||||
id = syntax.newnode(syntax.nkind.N_DOT, pf, pl, pc);
|
||||
id.lhs = syntax.newnode(syntax.nkind.N_IDENT, pf, pl, pc);
|
||||
|
||||
Reference in New Issue
Block a user