ww: recursive DIR/... package discovery for ww test
This commit is contained in:
@@ -443,6 +443,102 @@ fn packagepath(relative: str) str = {
|
||||
clean(root);
|
||||
};
|
||||
|
||||
// Go's ./... parity: a trailing "..." element walks the tree, one package
|
||||
// run per test-bearing directory, dot- and underscore-prefixed directory
|
||||
// names excluded. The excluded sentinels hold failing tests so a wrong
|
||||
// descent turns the whole run red rather than passing silently.
|
||||
@test fn recursive_tree_discovery() void = {
|
||||
let root: str = fresh();
|
||||
let tree: str = strings.concat(root, "/tree");
|
||||
assert(os.mkdir(tree, 448i32) == 0);
|
||||
assert(os.mkdir(strings.concat(tree, "/alpha"), 448i32) == 0);
|
||||
assert(os.mkdir(strings.concat(tree, "/beta"), 448i32) == 0);
|
||||
assert(os.mkdir(strings.concat(tree, "/beta/inner"), 448i32) == 0);
|
||||
assert(os.mkdir(strings.concat(tree, "/gamma"), 448i32) == 0);
|
||||
assert(os.mkdir(strings.concat(tree, "/.hidden"), 448i32) == 0);
|
||||
assert(os.mkdir(strings.concat(tree, "/_skip"), 448i32) == 0);
|
||||
writefile(strings.concat(tree, "/alpha/alpha.ww"),
|
||||
"package alpha;\nexport fn value() int = { return 7; };\n");
|
||||
writefile(strings.concat(tree, "/alpha/alpha_test.ww"),
|
||||
"package alpha_test;\nimport alpha;\n@test fn treealpha() void = { assert(alpha.value() == 7); };\n");
|
||||
writefile(strings.concat(tree, "/beta/inner/inner_test.ww"),
|
||||
"package inner;\n@test fn treeinner() void = { assert(1 == 1); };\n");
|
||||
writefile(strings.concat(tree, "/gamma/gamma.ww"),
|
||||
"package gamma;\nexport fn g() int = { return 1; };\n");
|
||||
writefile(strings.concat(tree, "/.hidden/hid_test.ww"),
|
||||
"package hid;\n@test fn hidden() void = { assert(false); };\n");
|
||||
writefile(strings.concat(tree, "/_skip/skip_test.ww"),
|
||||
"package skip;\n@test fn skipped() void = { assert(false); };\n");
|
||||
|
||||
let spec: str = strings.concat(tree, "/...");
|
||||
let outc: commandout;
|
||||
let outw: commandout;
|
||||
let treec: []str = [driver("ww"), "test", spec];
|
||||
let treew: []str = [driver("ww_ww"), "test", spec];
|
||||
runcommand(root, "tree-c", treec,
|
||||
(30i64 * (time.second: i64)): time.duration, &outc);
|
||||
runcommand(root, "tree-ww", treew,
|
||||
(30i64 * (time.second: i64)): time.duration, &outw);
|
||||
expectexit(&outc, 0);
|
||||
expectexit(&outw, 0);
|
||||
assert(same(outc.stdout, outw.stdout));
|
||||
assert(same(outc.stderr, outw.stderr));
|
||||
assert(has(outc.stdout, strings.concat("ok ", tree,
|
||||
"/alpha [alpha_test, external]\n")));
|
||||
assert(has(outc.stdout, strings.concat("ok ", tree,
|
||||
"/beta/inner [inner, same-package]\n")));
|
||||
assert(has(outc.stdout, strings.concat("? ", tree,
|
||||
"/gamma [no tests]\n")));
|
||||
assert(!has(outc.stdout, ".hidden"));
|
||||
assert(!has(outc.stdout, "_skip"));
|
||||
|
||||
let patc: []str = [driver("ww"), "test", spec, "glob*"];
|
||||
let patw: []str = [driver("ww_ww"), "test", spec, "glob*"];
|
||||
runcommand(root, "tree-pattern-c", patc, time.second, &outc);
|
||||
runcommand(root, "tree-pattern-ww", patw, time.second, &outw);
|
||||
expectexit(&outc, 2);
|
||||
expectexit(&outw, 2);
|
||||
assert(same(outc.stderr, outw.stderr));
|
||||
assert(has(outc.stderr, "ww test: pattern needs a single test file\n"));
|
||||
|
||||
let oc: []str = [driver("ww"), "test", "-o",
|
||||
strings.concat(root, "/stem"), spec];
|
||||
let ow: []str = [driver("ww_ww"), "test", "-o",
|
||||
strings.concat(root, "/stem"), spec];
|
||||
runcommand(root, "tree-o-c", oc, time.second, &outc);
|
||||
runcommand(root, "tree-o-ww", ow, time.second, &outw);
|
||||
expectexit(&outc, 2);
|
||||
expectexit(&outw, 2);
|
||||
assert(same(outc.stderr, outw.stderr));
|
||||
assert(has(outc.stderr, "ww test: -c/-S/-o need a single test file\n"));
|
||||
|
||||
let wdc: []str = [driver("ww"), "test", "-w", root, spec];
|
||||
let wdw: []str = [driver("ww_ww"), "test", "-w", root, spec];
|
||||
runcommand(root, "tree-w-c", wdc, time.second, &outc);
|
||||
runcommand(root, "tree-w-ww", wdw, time.second, &outw);
|
||||
expectexit(&outc, 2);
|
||||
expectexit(&outw, 2);
|
||||
assert(same(outc.stderr, outw.stderr));
|
||||
assert(has(outc.stderr, "ww test: -w needs a single test file\n"));
|
||||
|
||||
let bare: str = strings.concat(root, "/bare");
|
||||
assert(os.mkdir(bare, 448i32) == 0);
|
||||
assert(os.mkdir(strings.concat(bare, "/sub"), 448i32) == 0);
|
||||
let barec: []str = [driver("ww"), "test",
|
||||
strings.concat(bare, "/...")];
|
||||
let barew: []str = [driver("ww_ww"), "test",
|
||||
strings.concat(bare, "/...")];
|
||||
runcommand(root, "tree-bare-c", barec,
|
||||
(10i64 * (time.second: i64)): time.duration, &outc);
|
||||
runcommand(root, "tree-bare-ww", barew,
|
||||
(10i64 * (time.second: i64)): time.duration, &outw);
|
||||
expectexit(&outc, 1);
|
||||
expectexit(&outw, 1);
|
||||
assert(same(outc.stderr, outw.stderr));
|
||||
assert(has(outc.stderr, "directory contains no WW package sources\n"));
|
||||
clean(root);
|
||||
};
|
||||
|
||||
fn runtimepath(relative: str) str = {
|
||||
return strings.concat(repo(), "/test/package/runtime/", relative);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user