ww test: preserve combined product output order
Go 1.26.5 maps each test binary's stdout and stderr to the same product writer. Teach the captured executor to share one open file description for byte-equal output paths, then make directory test products emit that one ordered capture on coordinator stdout. Build captures and inherited-stdio routes remain unchanged.\n\nKeep the executor mechanism, package policy, native Cstage/WWstage proof, and normative contract together so every commit preserves the observable test-output behavior.
This commit is contained in:
@@ -29,7 +29,8 @@ export type result = struct {
|
||||
// command is deliberately concrete. argv includes argv[0], env is the full
|
||||
// environment, and an empty dir inherits the caller's working directory.
|
||||
// An empty stdinpath selects the null device; stdoutpath and stderrpath are
|
||||
// created exclusively with mode 0600. A zero deadline means no timeout.
|
||||
// created exclusively with mode 0600. Equal output paths share one open
|
||||
// capture. A zero deadline means no timeout.
|
||||
export type command = struct {
|
||||
path: str,
|
||||
argv: []str,
|
||||
@@ -120,6 +121,16 @@ fn hasnul(s: str) bool = {
|
||||
return false;
|
||||
};
|
||||
|
||||
fn samepath(a: str, b: str) bool = {
|
||||
if (a.len != b.len) { return false; };
|
||||
let i: i32 = 0;
|
||||
for (i < a.len) {
|
||||
if (a[i] != b[i]) { return false; };
|
||||
i += 1;
|
||||
};
|
||||
return true;
|
||||
};
|
||||
|
||||
fn valid(c: *command) bool = {
|
||||
if (c.path.len == 0 || c.argv.len == 0 || c.argv[0].len == 0) {
|
||||
return false;
|
||||
@@ -262,8 +273,14 @@ export fn start(p: *process, c: *command) void = {
|
||||
closefd(&p.result, infd);
|
||||
return;
|
||||
};
|
||||
let errfd: i32 = os.open(c.stderrpath,
|
||||
os.flag.WRONLY | os.flag.CREATE | os.flag.EXCL, 384);
|
||||
let errfd: i32;
|
||||
if (samepath(c.stdoutpath, c.stderrpath)) {
|
||||
errfd = syscall3(SYS_FCNTL, outfd: i64,
|
||||
F_DUPFD_CLOEXEC: i64, (os.STDERR_FILENO + 1): i64): i32;
|
||||
} else {
|
||||
errfd = os.open(c.stderrpath,
|
||||
os.flag.WRONLY | os.flag.CREATE | os.flag.EXCL, 384);
|
||||
};
|
||||
if (errfd < 0) {
|
||||
fail(p, errfd);
|
||||
closefd(&p.result, infd);
|
||||
|
||||
Reference in New Issue
Block a user