ww test: omit marker for empty list results
This commit is contained in:
@@ -844,7 +844,132 @@ fn cwdwritedata(dir: str, label: str) void = {
|
||||
runcommand(root, "list-nomatch", lnav,
|
||||
(30i64 * (time.second: i64)): time.duration, &out);
|
||||
expectexit(&out, 0);
|
||||
assert(occurrences(out.stdout, "[no matches]\n") == 1);
|
||||
assert(occurrences(out.stdout, "[no matches]\n") == 0);
|
||||
assert(!has(out.stdout, " discovered, "));
|
||||
clean(root);
|
||||
};
|
||||
|
||||
@test fn list_mode_with_no_matches_emits_no_sentinel() void = {
|
||||
let root: str = fresh();
|
||||
let alpha: str = strings.concat(root, "/alpha");
|
||||
let beta: str = strings.concat(root, "/beta");
|
||||
mkdirall(alpha);
|
||||
mkdirall(beta);
|
||||
writefile(strings.concat(alpha, "/alpha.ww"), strings.concat(
|
||||
"package list_alpha;\nimport os;\n",
|
||||
"fn init() void = { os.write(os.STDOUT_FILENO,",
|
||||
" \"alpha-init\\n\".ptr, 11u64); };\n"));
|
||||
writefile(strings.concat(alpha, "/alpha_internal_test.ww"),
|
||||
strings.concat(
|
||||
"package list_alpha;\n",
|
||||
"@test fn first() void = { abort(\"selected first\"); };\n",
|
||||
"@test fn second() void = { abort(\"selected second\"); };\n"));
|
||||
writefile(strings.concat(alpha, "/alpha_external_test.ww"),
|
||||
strings.concat(
|
||||
"package list_alpha_test;\n",
|
||||
"@test fn external() void = { abort(\"selected external\"); };\n"));
|
||||
writefile(strings.concat(beta, "/beta_test.ww"), strings.concat(
|
||||
"package list_beta_test;\nimport os;\n",
|
||||
"fn init() void = { os.write(os.STDOUT_FILENO,",
|
||||
" \"beta-init\\n\".ptr, 10u64); };\n",
|
||||
"@test fn only() void = { abort(\"selected only\"); };\n"));
|
||||
|
||||
let stages: []str = ["ww", "ww_ww"];
|
||||
let tags: []str = ["c", "ww"];
|
||||
let works: []str = [strings.concat(root, "/work-c"),
|
||||
strings.concat(root, "/work-ww")];
|
||||
let coldout: []str = ["", ""];
|
||||
let colderror: []str = ["", ""];
|
||||
let positiveout: []str = ["", ""];
|
||||
let positiveerror: []str = ["", ""];
|
||||
let retainedout: []str = ["", ""];
|
||||
let retainederror: []str = ["", ""];
|
||||
let manualout: []str = ["", ""];
|
||||
let manualerror: []str = ["", ""];
|
||||
let retained: []str = [strings.concat(root, "/retained-c.test"),
|
||||
strings.concat(root, "/retained-ww.test")];
|
||||
let out: commandout;
|
||||
let i: i32 = 0;
|
||||
for (i < stages.len) {
|
||||
let emptyav: []str = [driver(stages[i]), "test", "-j", "2",
|
||||
"-w", works[i], "-list", "-run", "no-such-*", alpha,
|
||||
beta];
|
||||
runcommand(root, strings.concat("list-empty-cold-", tags[i]),
|
||||
emptyav, (90i64 * (time.second: i64)): time.duration, &out);
|
||||
expectexit(&out, 0);
|
||||
assert(out.stderr.len == 0);
|
||||
assert(occurrences(out.stdout, "alpha-init\n") == 1);
|
||||
assert(occurrences(out.stdout, "beta-init\n") == 1);
|
||||
assert(occurrences(out.stdout, "ok ") == 2);
|
||||
assert(!has(out.stdout, "[no matches]"));
|
||||
assert(!has(out.stdout, " discovered, "));
|
||||
assert(!has(out.stdout, "list_alpha.first"));
|
||||
assert(!has(out.stdout, "list_alpha.second"));
|
||||
assert(!has(out.stdout, "list_alpha.external"));
|
||||
assert(!has(out.stdout, "list_beta.only"));
|
||||
coldout[i] = strings.dup(out.stdout);
|
||||
colderror[i] = strings.dup(out.stderr);
|
||||
|
||||
runcommand(root, strings.concat("list-empty-warm-", tags[i]),
|
||||
emptyav, (90i64 * (time.second: i64)): time.duration, &out);
|
||||
expectexit(&out, 0);
|
||||
assert(same(out.stdout, coldout[i]));
|
||||
assert(same(out.stderr, colderror[i]));
|
||||
assert(!directoryhasnew(works[i]));
|
||||
|
||||
let positiveav: []str = [driver(stages[i]), "test", "-j", "2",
|
||||
"-w", works[i], "-list", alpha, beta];
|
||||
runcommand(root, strings.concat("list-positive-", tags[i]),
|
||||
positiveav, (90i64 * (time.second: i64)): time.duration, &out);
|
||||
expectexit(&out, 0);
|
||||
assert(out.stderr.len == 0);
|
||||
let first: i32 = pos(out.stdout, "list_alpha.first\n");
|
||||
let second: i32 = pos(out.stdout, "list_alpha.second\n");
|
||||
let external: i32 = pos(out.stdout, "list_alpha.external\n");
|
||||
let only: i32 = pos(out.stdout, "list_beta.only\n");
|
||||
assert(first >= 0 && first < second && second < external
|
||||
&& external < only);
|
||||
assert(occurrences(out.stdout, "list_alpha.first\n") == 1);
|
||||
assert(occurrences(out.stdout, "list_alpha.second\n") == 1);
|
||||
assert(occurrences(out.stdout, "list_alpha.external\n") == 1);
|
||||
assert(occurrences(out.stdout, "list_beta.only\n") == 1);
|
||||
positiveout[i] = strings.dup(out.stdout);
|
||||
positiveerror[i] = strings.dup(out.stderr);
|
||||
|
||||
let retainav: []str = [driver(stages[i]), "test", "-w",
|
||||
works[i], "-o", retained[i], "-list", "-run",
|
||||
"no-such-*", alpha];
|
||||
runcommand(root, strings.concat("list-retained-", tags[i]),
|
||||
retainav, (90i64 * (time.second: i64)): time.duration, &out);
|
||||
expectexit(&out, 0);
|
||||
assert(out.stderr.len == 0);
|
||||
assert(occurrences(out.stdout, "alpha-init\n") == 1);
|
||||
assert(occurrences(out.stdout, "ok ") == 1);
|
||||
assert(!has(out.stdout, "[no matches]"));
|
||||
assert(!has(out.stdout, "list_alpha."));
|
||||
assert(os.exists(retained[i]));
|
||||
retainedout[i] = strings.dup(out.stdout);
|
||||
retainederror[i] = strings.dup(out.stderr);
|
||||
|
||||
let manualav: []str = [retained[i], "-list", "no-such-*"];
|
||||
runcommand(root, strings.concat("list-manual-", tags[i]), manualav,
|
||||
(30i64 * (time.second: i64)): time.duration, &out);
|
||||
expectexit(&out, 0);
|
||||
assert(same(out.stdout, "alpha-init\n"));
|
||||
assert(out.stderr.len == 0);
|
||||
manualout[i] = strings.dup(out.stdout);
|
||||
manualerror[i] = strings.dup(out.stderr);
|
||||
i += 1;
|
||||
};
|
||||
assert(same(coldout[0], coldout[1]));
|
||||
assert(same(colderror[0], colderror[1]));
|
||||
assert(same(positiveout[0], positiveout[1]));
|
||||
assert(same(positiveerror[0], positiveerror[1]));
|
||||
assert(same(retainedout[0], retainedout[1]));
|
||||
assert(same(retainederror[0], retainederror[1]));
|
||||
assert(same(manualout[0], manualout[1]));
|
||||
assert(same(manualerror[0], manualerror[1]));
|
||||
assert(same(readfile(retained[0]), readfile(retained[1])));
|
||||
clean(root);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user