trun: Fix returncode when test run is canceled
To detect leaked processes in the end of the run, we are first waiting for remaining test processes via procps. If the main waiting loop was canceled without main test process first completed (p.poll calls never returned !None), then the waitpid(pid=p.pid) system call will be done via procps. Which leaves further waitpid(pid=p.pid) system call invoked by subprocess to get -ECHILD error and artificially report 0 exit status: https://github.com/python/cpython/blob/2.7-0-g8d21aa21f2c/Lib/subprocess.py#L1094-L1107 -> Fix it by propagating .returncode from procps to Popen instance so that it does not get lost. On sample .nxdtest with TestCase('sleep', ['sleep', '10']) Before the patch the output with CTRL+C was: $ nxdtest ... >>> sleep $ sleep 10 ^C# Interrupt ok sleep 0.604s # 1t 0e 0f 0s <-- NOTE # test run canceled # ran 1 test case: 1·ok <-- NOTE After the patch the output becomes: $ nxdtest ... >>> sleep $ sleep 100 ^C# Interrupt error sleep 1.006s # 1t 1e 0f 0s <-- NOTE # test run canceled # ran 1 test case: 1·error <-- NOTE /reviewed-by @jerome /reviewed-on nexedi/nxdtest!16
Showing
Please register or sign in to comment