luatest icon indicating copy to clipboard operation
luatest copied to clipboard

Make stdout linebuffered

Open rosik opened this issue 5 years ago • 2 comments

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)

rosik avatar May 30 '19 22:05 rosik

I'm not sure it's still relevant. Need to find a reproducer that damages the output. Otherwise, it has no sense.

rosik avatar Sep 03 '21 16:09 rosik

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.

Totktonada avatar Jun 20 '23 11:06 Totktonada