• Kirill Smelkov's avatar
    Cancel test run on SIGINT/SIGTERM · b0cf277d
    Kirill Smelkov authored
    In addition to canceling test run is master tells us to do so, also cancel the
    run if interrupted or terminated.
    
    With the following sample .nxdtest
    
        TestCase('sleep', ['sleep', '10'])
    
    before the patch it does not react to CTRL+C:
    
        $ nxdtest
        ...
        >>> sleep
        $ sleep 10
        ^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C^C# ran 0 test cases.   <-- no reaction to CTRL+C, finishes after 10 seconds
        Traceback (most recent call last):
          File "/home/kirr/src/tools/go/py3.venv2/bin/nxdtest", line 33, in <module>
            sys.exit(load_entry_point('nxdtest', 'console_scripts', 'nxdtest')())
          File "/home/kirr/src/tools/go/py3.venv2/lib/python3.9/site-packages/decorator.py", line 232, in fun
            return caller(func, *(extras + args), **kw)
          File "/home/kirr/src/tools/go/pygolang-master/golang/__init__.py", line 103, in _
            return f(*argv, **kw)
          File "/home/kirr/src/wendelin/nxdtest/nxdtest/__init__.py", line 339, in main
            wg.wait()
        KeyboardInterrupt
    
    after the patch:
    
        $ nxdtest
        ...
        >>> sleep
        $ sleep 10
        ^C# Interrupt					<-- prompt reaction to CTRL+C
        # stopping due to cancel
        # leaked pid=188877 'sleep' ['sleep', '10']
        error   sleep   1.030s  # 1t 1e 0f 0s
        # test run canceled
        # ran 1 test case:  1·error
    
    Needs nexedi/pygolang!17 to work.
    
    /reviewed-by @jerome
    /reviewed-on nexedi/nxdtest!16
    b0cf277d
setup.py 976 Bytes