“Solution”, at the end of the day:
All varieties work from within main(); none work from a testing block. (Of course, within main(), you can’t use std.testing.io.) Also, flush() is essential, as probably supposed, though flush() hangs indefinitely from within a test block. The most no-nonsense way to do this from main is to just use juicy:
pub fn main(init: std.process.Init) !void {
const f = std.Io.File.stdout();
var buf: [512]u8 = undefined;
var w = f.writer(init.io, &buf);
//OR: var w: std.Io.File.Writer = .init(.stdout(), init.io, &buf); // instead of File.stdout() above
_ = try w.interface.write("hello there\n");
// (my actual code sends w.interface to the function that takes a Writer)
try w.interface.flush();
}
Edit: explanations for why stdout doesn’t work from a test block are provided below by @miagi and @vulpesx; in short: stderr should work, but causes a test to fail, and stdout is unavailable.