compiler: support package test runtime aliases
This commit is contained in:
@@ -66,6 +66,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
let src: *u8 = nil;
|
||||
let out: *u8 = nil;
|
||||
let wwiout: *u8 = nil; // -I <out.wwi>: M2 export-data producer
|
||||
let testsupport: *u8 = nil;
|
||||
let testmode: i32 = 0i32; // #15: `-T` test-mode
|
||||
let sepmode: i32 = 0i32; // -c: #22 M3 separate-compile / primary-
|
||||
// only codegen (emit imported==0 decls
|
||||
@@ -92,6 +93,14 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
wwiout = argv[i];
|
||||
} else { if (cstreq(a, "-T")) {
|
||||
testmode = 1i32;
|
||||
} else { if (cstreq(a, "--test-support-module")) {
|
||||
i += 1;
|
||||
if (i >= argc) {
|
||||
let m: str = "w6c: --test-support-module requires arg\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
testsupport = argv[i];
|
||||
} else { if (cstreq(a, "-c")) {
|
||||
sepmode = 1i32;
|
||||
} else { if (a[0u64] == 45u8) {
|
||||
@@ -105,7 +114,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
return 2;
|
||||
};
|
||||
src = a;
|
||||
}; }; }; }; };
|
||||
}; }; }; }; }; };
|
||||
i += 1;
|
||||
};
|
||||
|
||||
@@ -114,6 +123,13 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
if (testsupport != nil && (sepmode == 0
|
||||
|| (!cstreq(testsupport, "test")
|
||||
&& !cstreq(testsupport, "__wwtest")))) {
|
||||
let m: str = "w6c: invalid --test-support-module\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
|
||||
let buf: *u8;
|
||||
let blen: u64;
|
||||
@@ -155,6 +171,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
|
||||
let ps: parser;
|
||||
parserinit(&ps, &l);
|
||||
if (testsupport != nil) { ps.testmodule = pathstr(testsupport); };
|
||||
let f: *node = parsefile(&ps);
|
||||
// Gate cgen on parse-stage errors. Mirrors cmd/w6c/main.c's
|
||||
// `if (l.errs || p.errs) return 1;` — broken AST otherwise reaches
|
||||
@@ -172,6 +189,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
let ck: checker;
|
||||
checkinit(&ck, &tc);
|
||||
ck.istest = testmode;
|
||||
if (testsupport != nil) { ck.testmodule = pathstr(testsupport); };
|
||||
ck.sepmode = sepmode;
|
||||
checkfile(&ck, f);
|
||||
if (ck.errs > 0) { return 1; };
|
||||
|
||||
Reference in New Issue
Block a user