• Kirill Smelkov's avatar
    trun: Fix returncode when test run is canceled · 56e52da6
    Kirill Smelkov authored
    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
    -> 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 !16
Last commit
Last update
nxdtest Loading commit data...
.gitignore Loading commit data...
.nxdtest Loading commit data...
COPYING Loading commit data...
pytest.ini Loading commit data...
setup.py Loading commit data...