saleyn / erlexec

Execute and control OS processes from Erlang/OTP
https://hexdocs.pm/erlexec/readme.html
Other
525 stars 139 forks source link

Fix tests #165

Closed SteffenDE closed 2 years ago

SteffenDE commented 2 years ago

Work in progress

saleyn commented 2 years ago

I made it a little easier to see the test match reasons in CI: https://github.com/saleyn/erlexec/runs/7321194951?check_suite_focus=true

This also shows that in CI the output may get broken, so that <<"test\r\n">> may be received as [<<"test">>, <<"\r\n">>], which complicates matching a bit.

saleyn commented 2 years ago

I also tried to fix the patter matching in receiving binary data. Please look at the latest. Only PTY tests are failing now in CI.

SteffenDE commented 2 years ago

Yeah my change is probably not needed then; I see the Cmd given as a unicode string part failing and one in the winsz test. Looking at the winsz test now.

saleyn commented 2 years ago

If tput is still failing, maybe try tput -T xterm lines cols?

SteffenDE commented 2 years ago

Yeah that is already fixed by putting TERM into the env; only the test with the unicode filename is still reliably failing.

saleyn commented 2 years ago

I think the issue with PTY is that it doesn't distinguish between stdout and stderr (this was reported by another user a while back). Consequently, doing DEBUG printout while using pty will fail the tests. Perhaps there is solution to this, but I haven't found.

SteffenDE commented 2 years ago

Yeah, I turned the PORT_DEBUG option off. I thought about adding some kind of IO process that provides a function like gen_tcp active false mode where one has to manually call recv with the number of bytes. Currently my tests are flaky as the case of a message longer than expected arriving can cause the order of data to be wrong.

https://github.com/SteffenDE/erlexec/blob/6700e9c19b80d26b42edc29ceb24f7e6b3b2d0f7/src/exec.erl#L1452-L1453

saleyn commented 2 years ago

Thank you very much!

SteffenDE commented 2 years ago

Sorry for the back and forth; your check_receive function combined with the PORT_DEBUG log confused me, therefore I unnecessarily moved back to my receiveBytes function. One might see that I'm coming from the Elixir world and my Erlang is rather bad, but in the end I moved back to your solution as it works fine.

The only real changes are the macOS pipeline fix, as well as the assertion for the long "test\r\ntest\r\n". Thanks for the patience 😄