Ticket #14430: trac_14430_report_worker_pid.patch

File trac_14430_report_worker_pid.patch, 5.2 KB (added by vbraun, 9 years ago)

Initial patch

  • sage/doctest/forker.py

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1365509297 -3600
    # Node ID 60223b6345f09bfdcacb1f767c13934543d0b760
    # Parent  dde304b671ecec8932f85272c6d424864250db2a
    Report the pid of the worker if a test fails
    
    diff --git a/sage/doctest/forker.py b/sage/doctest/forker.py
    a b  
    15061506                                w.killed,
    15071507                                w.exitcode,
    15081508                                w.result,
    1509                                 w.output)
     1509                                w.output,
     1510                                pid=w.pid)
    15101511                            restart = True
    15111512                            follow = None
    15121513                    finished = new_finished
  • sage/doctest/reporting.py

    diff --git a/sage/doctest/reporting.py b/sage/doctest/reporting.py
    a b  
    151151        cmd += " " + source.printpath
    152152        return cmd
    153153
    154     def report(self, source, timeout, return_code, results, output):
     154    def report(self, source, timeout, return_code, results, output, pid=None):
    155155        """
    156156        Report on the result of running doctests on a given source.
    157157
     
    179179        - ``output`` -- a string, printed if there was some kind of
    180180          failure
    181181
     182        - ``pid`` -- optional integer (default: ``None``). The pid of
     183          the worker process.
     184
    182185        EXAMPLES::
    183186
    184187            sage: from sage.doctest.reporting import DocTestReporter
     
    197200
    198201        You can report a timeout::
    199202
    200             sage: DTR.report(FDS, True, 0, None, "Output so far...")
     203            sage: DTR.report(FDS, True, 0, None, "Output so far...", pid=1234)
    201204                Time out
    202205            **********************************************************************
    203             Tests run before process timed out:
     206            Tests run before process (pid=1234) timed out:
    204207            Output so far...
    205208            **********************************************************************
    206209            sage: DTR.stats
     
    298301            AttributeError: 'NoneType' object has no attribute 'basename'
    299302        """
    300303        log = self.controller.log
     304        process_name = 'process (pid={0})'.format(pid) if pid else 'process'
    301305        try:
    302306            postscript = self.postscript
    303307            stats = self.stats
     
    322326                        fail_msg += " (and interrupt failed)"
    323327                    else:
    324328                        fail_msg += " (with %s after interrupt)"%signal_name(sig)
    325                 log("    %s\n%s\nTests run before process timed out:"%(fail_msg, "*"*70))
     329                log("    %s\n%s\nTests run before %s timed out:"%(fail_msg, "*"*70, process_name))
    326330                log(output)
    327331                log("*"*70)
    328332                postscript['lines'].append(cmd + "  # %s"%fail_msg)
     
    335339                    fail_msg = "Killed due to %s"%signal_name(-return_code)
    336340                if ntests > 0:
    337341                    fail_msg += " after testing finished"
    338                 log("    %s\n%s\nTests run before process failed:"%(fail_msg,"*"*70))
     342                log("    %s\n%s\nTests run before %s failed:"%(fail_msg,"*"*70, process_name))
    339343                log(output)
    340344                log("*"*70)
    341345                postscript['lines'].append(cmd + "  # %s" % fail_msg)
     
    465469
    466470        Now we pretend to run some doctests::
    467471
    468             sage: DTR.report(FDS, True, 0, None, "Output so far...")
     472            sage: DTR.report(FDS, True, 0, None, "Output so far...", pid=1234)
    469473                Time out
    470474            **********************************************************************
    471             Tests run before process timed out:
     475            Tests run before process (pid=1234) timed out:
    472476            Output so far...
    473477            **********************************************************************
    474478            sage: DTR.report(FDS, False, 3, None, "Output before bad exit")
  • sage/doctest/test.py

    diff --git a/sage/doctest/test.py b/sage/doctest/test.py
    a b  
    8585    sage -t 99seconds.rst
    8686        Time out
    8787    **********************************************************************
    88     Tests run before process timed out:
     88    Tests run before process (pid=...) timed out:
    8989    ...
    9090    ----------------------------------------------------------------------
    9191    sage -t 99seconds.rst  # Time out
     
    169169    sage -t abort.rst
    170170        Killed due to abort
    171171    **********************************************************************
    172     Tests run before process failed:
     172    Tests run before process (pid=...) failed:
    173173    ...
    174174    ------------------------------------------------------------------------
    175175    Unhandled SIGABRT: An abort() occurred in Sage.
     
    201201        NameError: name 'this_gives_a_NameError' is not defined
    202202        Killed due to kill signal
    203203    **********************************************************************
    204     Tests run before process failed:
     204    Tests run before process (pid=...) failed:
    205205    ...
    206206    ----------------------------------------------------------------------
    207207    sage -t fail_and_die.rst  # Killed due to kill signal