ww: resolve root argv0 and retire stale help paths
This commit is contained in:
@@ -73,6 +73,28 @@ fn rundrv(root: str, name: str, drv: str, argv: []str,
|
||||
assert(out.termination == exec.termination.EXIT);
|
||||
};
|
||||
|
||||
fn runrootargv(dir: str, root: str, name: str, drv: str,
|
||||
out: *testenv.commandout) void = {
|
||||
let av: []str = ["/ww", "build", "rootprobe"];
|
||||
let env: []str = ["PATH=/usr/bin:/bin", "LC_ALL=C"];
|
||||
let c: exec.command;
|
||||
c.path = testenv.driver(drv);
|
||||
c.argv = av;
|
||||
c.env = env;
|
||||
c.dir = dir;
|
||||
c.stdoutpath = strings.concat(root, "/", name, ".stdout");
|
||||
c.stderrpath = strings.concat(root, "/", name, ".stderr");
|
||||
c.deadline = time.add(time.now(time.clock.monotonic), tmo());
|
||||
c.grace = (100i64 * (time.millisecond: i64)): time.duration;
|
||||
let r: exec.result;
|
||||
exec.run(&c, &r);
|
||||
assert(r.errno == 0 && r.cleanuperrno == 0);
|
||||
out.termination = r.termination;
|
||||
out.code = r.code;
|
||||
out.stdout = testenv.readfile(c.stdoutpath);
|
||||
out.stderr = testenv.readfile(c.stderrpath);
|
||||
};
|
||||
|
||||
@test fn version() void = {
|
||||
let td: str = testenv.fresh();
|
||||
let want: str = strings.concat("ww ", wwversion(), "\n");
|
||||
@@ -92,6 +114,56 @@ fn rundrv(root: str, name: str, drv: str, argv: []str,
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
@test fn help() void = {
|
||||
let td: str = testenv.fresh();
|
||||
let tail: []str = ["-h"];
|
||||
let co: testenv.commandout;
|
||||
let wo: testenv.commandout;
|
||||
rundrv(td, "help_c", "ww", tail, &co);
|
||||
rundrv(td, "help_w", "ww_ww", tail, &wo);
|
||||
if (co.code != 0 || wo.code != 0
|
||||
|| !testenv.same(co.stdout, wo.stdout)
|
||||
|| co.stderr.len != 0 || wo.stderr.len != 0) {
|
||||
fail("help", "driver help is not byte-identical on stdout");
|
||||
};
|
||||
if (testenv.has(co.stdout, "foo/foo.ww")
|
||||
|| testenv.has(co.stdout, "fmt <path>")) {
|
||||
fail("help", "driver help advertises a retired path or command");
|
||||
};
|
||||
let fmttail: []str = ["fmt"];
|
||||
rundrv(td, "fmt_c", "ww", fmttail, &co);
|
||||
rundrv(td, "fmt_w", "ww_ww", fmttail, &wo);
|
||||
if (co.code != 2 || wo.code != co.code
|
||||
|| !testenv.same(co.stdout, wo.stdout)
|
||||
|| !testenv.same(co.stderr, wo.stderr)
|
||||
|| !testenv.has(co.stderr, "unknown subcommand: fmt")) {
|
||||
fail("help", "retired fmt command is not an identical unknown command");
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
@test fn rootargv0() void = {
|
||||
let td: str = testenv.fresh();
|
||||
let lib: str = strings.concat(td, "/lib");
|
||||
let a: str = strings.concat(td, "/a");
|
||||
let wd: str = strings.concat(a, "/b");
|
||||
assert(os.mkdir(lib, 448i32) == 0);
|
||||
assert(os.mkdir(a, 448i32) == 0);
|
||||
assert(os.mkdir(wd, 448i32) == 0);
|
||||
testenv.writefile(strings.concat(lib, "/rootprobe.ww"),
|
||||
"package main;\nexport fn main() i32 = { return 0; };\n");
|
||||
let co: testenv.commandout;
|
||||
let wo: testenv.commandout;
|
||||
runrootargv(wd, td, "rootargv_c", "ww", &co);
|
||||
runrootargv(wd, td, "rootargv_w", "ww_ww", &wo);
|
||||
if (co.code == 0 || wo.code == 0
|
||||
|| !testenv.has(co.stderr, "cannot find module")
|
||||
|| !testenv.has(wo.stderr, "cannot find module")) {
|
||||
fail("rootargv0", "argv0 /ww did not resolve selfdir as /");
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
// a3 == "" means a two-token argv tail; no row passes a literal "".
|
||||
@test fn flagargs() void = {
|
||||
let a1: []str = ["build", "build", "build", "build", "build",
|
||||
|
||||
Reference in New Issue
Block a user