luatest
luatest copied to clipboard
Rewrite Process in Popen
Also such approach should preserve backward compatibility (old versions should use old code). But new Tarantool versions 2.4 should works fine. Maybe it will fix https://github.com/tarantool/luatest/issues/120 .
During solution #252 , we tried to rewrite the module, but decided to postpone it indefinitely. These are notes about what we managed to find out (for the future):
- list of possible problems with popen;
ffi pipeandpopen popenare not compatible (by interfaces);output_beatifier:hijack_output(...)not needed becausePOPENwill do it; https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/process.lua#L64-L66- processing of arguments and environment variables is not necessary: https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/process.lua#L67-L68
- there are some limitations in
popen:new(), you need to usepopen:shell(); - you can replace the
readfunction (a more correct option): https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/ffi_io.lua#L32-L47 - see #312 about this logic (diagram) https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/process.lua#L51-L59
ffi.gcworks correctly withpopenhttps://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/process.lua#L78-L81
ffi pipe and popen popen are not compatible (by interfaces);
This issue was written when 1.10 was relevant. Currently it's not so. You don't need to care about ffi and popen compatibility.