test: resolve byte-id fixtures as directory packages
This commit is contained in:
@@ -29,10 +29,9 @@ package libbyteid_test;
|
||||
// graduation pinned the same way.
|
||||
//
|
||||
// Fixtureless modules are covered by import-probe stubs: `import`
|
||||
// drags the whole module into its own sep package. The driver silently
|
||||
// skips an unresolvable import, so each probe carries a sentinel that
|
||||
// must appear in a per-package .unit.ww, and the completeness scan
|
||||
// fails loudly on any lib/ dir not enrolled here.
|
||||
// drags the whole directory module into its own sep package. Each probe
|
||||
// carries a sentinel that must appear in a per-package .unit.ww, and
|
||||
// the completeness scan fails loudly on any lib/ dir not enrolled here.
|
||||
|
||||
import os;
|
||||
import os.exec;
|
||||
@@ -105,18 +104,18 @@ fn corpus() []ent = {
|
||||
append(es, fx("lib/bytes/tokenize_test.ww"));
|
||||
append(es, fx("lib/bytes/trim_test.ww"));
|
||||
append(es, fx("lib/dirs/dirs_test.ww"));
|
||||
append(es, fx("lib/encoding/base32/base32_test.ww"));
|
||||
append(es, fxi("lib/encoding/base32/base32_test.ww", "lib/encoding"));
|
||||
append(es, fx("lib/encoding/hex/hex_test.ww"));
|
||||
append(es, fx("lib/encoding/utf8/rune_test.ww"));
|
||||
append(es, fx("lib/encoding/utf8/encode_test.ww"));
|
||||
append(es, fx("lib/encoding/utf8/decode_test.ww"));
|
||||
append(es, fx("lib/encoding/utf8/types_test.ww"));
|
||||
append(es, fx("lib/getopt/getopt_test.ww"));
|
||||
append(es, fx("lib/hash/adler32/adler32_test.ww"));
|
||||
append(es, fx("lib/hash/crc16/crc16_test.ww"));
|
||||
append(es, fx("lib/hash/crc32/crc32_test.ww"));
|
||||
append(es, fx("lib/hash/crc64/crc64_test.ww"));
|
||||
append(es, fx("lib/hash/siphash/siphash_test.ww"));
|
||||
append(es, fxi("lib/hash/adler32/adler32_test.ww", "lib/hash"));
|
||||
append(es, fxi("lib/hash/crc16/crc16_test.ww", "lib/hash"));
|
||||
append(es, fxi("lib/hash/crc32/crc32_test.ww", "lib/hash"));
|
||||
append(es, fxi("lib/hash/crc64/crc64_test.ww", "lib/hash"));
|
||||
append(es, fxi("lib/hash/siphash/siphash_test.ww", "lib/hash"));
|
||||
append(es, fx("lib/math/checked/checked_test.ww"));
|
||||
append(es, fx("lib/math/random/random_test.ww"));
|
||||
append(es, fx("lib/memio/memio_test.ww"));
|
||||
@@ -147,11 +146,12 @@ fn corpus() []ent = {
|
||||
"package net;", "lib/net"));
|
||||
append(es, pr("package main;\nimport hash;\nfn main() i32 = { return 0; };\n",
|
||||
"package hash;", "lib/hash"));
|
||||
// fnv lives off the driver's default root (lib/hash/fnv)
|
||||
// fnv lives below the driver's default root, so its canonical
|
||||
// directory is found from the explicit parent import root.
|
||||
append(es, pri("package main;\nimport fnv;\nfn main() i32 = { return 0; };\n",
|
||||
"lib/hash/fnv", "package fnv;", "lib/hash/fnv"));
|
||||
// sentinel is a fn, not `package math;` — lib/math is also package
|
||||
// math, so a silent fallback there would still match
|
||||
"lib/hash", "package fnv;", "lib/hash/fnv"));
|
||||
// Sentinel is a fn, not `package math;` — lib/math is also package
|
||||
// math, so the package clause alone would not prove the right body.
|
||||
append(es, pr("package main;\nimport crypto.math;\nfn main() i32 = { return 0; };\n",
|
||||
"fn rotl32", "lib/crypto/math"));
|
||||
append(es, pr("package main;\nimport c.libc;\nfn main() i32 = { return 0; };\n",
|
||||
@@ -162,7 +162,7 @@ fn corpus() []ent = {
|
||||
// sentinel: there is no dep unit to prove.
|
||||
append(es, pr("package main;\nfn main() i32 = { return 0; };\n", "", ""));
|
||||
append(es, fx("lib/ascii/ascii_test.ww"));
|
||||
append(es, fx("lib/encoding/base64/base64_test.ww"));
|
||||
append(es, fxi("lib/encoding/base64/base64_test.ww", "lib/encoding"));
|
||||
append(es, fx("lib/errors/errno_test.ww"));
|
||||
append(es, fx("lib/log/funcs_test.ww"));
|
||||
append(es, fx("lib/log/global_test.ww"));
|
||||
@@ -303,15 +303,11 @@ fn checkone(e: *ent) void = {
|
||||
testenv.writefile(strings.concat(td, "/", base), body);
|
||||
}; };
|
||||
|
||||
// dirname(fixture) leads the search path so bare same-module
|
||||
// imports resolve as they do under the in-tree driver run.
|
||||
// Most packages resolve from the driver's canonical lib/ root.
|
||||
// Nested packages whose tests use a bare leaf import carry an
|
||||
// explicit parent root in `inc`; pointing at the package directory
|
||||
// itself would depend on the retired <import>.ww fallback.
|
||||
let incs: []str = [];
|
||||
if (e.fixture.len != 0) {
|
||||
append(incs, strings.concat(testenv.repo(), "/",
|
||||
dirnameof(e.fixture)));
|
||||
} else { if (e.probe.len == 0 && e.moddir.len != 0) {
|
||||
append(incs, strings.concat(testenv.repo(), "/", e.moddir));
|
||||
}; };
|
||||
if (e.inc.len != 0) {
|
||||
append(incs, strings.concat(testenv.repo(), "/", e.inc));
|
||||
};
|
||||
@@ -338,10 +334,9 @@ fn checkone(e: *ent) void = {
|
||||
fail(label, "cstage produced no resolved unit");
|
||||
};
|
||||
|
||||
// probe coverage: the driver SILENTLY SKIPS an unresolvable
|
||||
// import, shrinking the probe to an empty main that byte-ids
|
||||
// trivially. The sentinel must appear in some per-package
|
||||
// .unit.ww to prove the module landed.
|
||||
// Probe coverage: resolution failures are loud, and the sentinel
|
||||
// additionally proves that the expected directory body (rather
|
||||
// than an accidental same-name package) landed.
|
||||
if (e.sentinel.len != 0) {
|
||||
let sepc: str = strings.concat(stemc, ".sepwork");
|
||||
let names: []str = testenv.listdir(sepc);
|
||||
|
||||
Reference in New Issue
Block a user