luatest
luatest copied to clipboard
Make stdout linebuffered
Since you redirect both stdout and stderr to a pipe and capture it together, both should be linebuffered to produce nice output.
Here is a PoC:
local ffi = require('ffi')
ffi.cdef([[
typedef struct __IO_FILE FILE;
void setlinebuf(FILE *stream);
FILE *stdout;
FILE *stderr;
]])
ffi.C.setlinebuf(ffi.C.stdout)
ffi.C.setlinebuf(ffi.C.stderr)
I'm not sure it's still relevant. Need to find a reproducer that damages the output. Otherwise, it has no sense.
NB: There is io.stdout:setvbuf('line')
and io.stderr:setvbuf('line')
. See here.
NB 2: libc's stdio buffering is a headache and I would avoid it where possible. See https://github.com/tarantool/test-run/pull/394.