Ticket #12415: 12415_review_review.patch

File 12415_review_review.patch, 7.7 KB (added by roed, 7 years ago)
  • sage/doctest/control.py

    # HG changeset patch
    # User Jeroen Demeyer <jdemeyer@cage.ugent.be>
    # Date 1361973198 -3600
    # Node ID f2b2bce7579c2d732cdef2db306cc2f94b6c214d
    # Parent  c7b751daeaf5c488a4a52afa89212376e791edef
    #12415: changes to Jeroen's changes
    
    diff --git a/sage/doctest/control.py b/sage/doctest/control.py
    a b  
    379379    def expand_files_into_sources(self):
    380380        """
    381381        Expands ``self.files``, which may include directories, into a
    382         list of :class:sage.doctest.FileDocTestSource
     382        list of :class:`sage.doctest.FileDocTestSource`
    383383
    384384        This function also handles the optional command line option.
    385385
     
    621621            sage: print DC._assemble_cmd()
    622622            python "$SAGE_LOCAL/bin/sage-runtests" --serial --timeout=300 hello_world.py
    623623        """
    624         cmd = '''python "$SAGE_LOCAL/bin/sage-runtests" --serial '''
     624        cmd = '''python "%s" --serial '''%(os.path.join("$SAGE_LOCAL","bin","sage-runtests"))
    625625        opt = dict_difference(self.options.__dict__, DocTestDefaults().__dict__)
    626626        for o in ("all", "sagenb"):
    627627            if o in opt:
     
    690690                flags = os.getenv("SAGE_MEMCHECK_FLAGS")
    691691                if flags is None:
    692692                    flags = "--leak-resolution=high --leak-check=full --num-callers=25 "
    693                     flags += '''--suppressions="$SAGE_LOCAL/lib/valgrind/sage.supp" '''
     693                    flags += '''--suppressions="%s" '''%(os.path.join("$SAGE_LOCAL","lib","valgrind","sage.supp"))
    694694            elif opt.massif:
    695695                toolname = "massif"
    696696                flags = os.getenv("SAGE_MASSIF_FLAGS", "--depth=6 ")
  • sage/doctest/forker.py

    diff --git a/sage/doctest/forker.py b/sage/doctest/forker.py
    a b  
    14661466                                pass
    14671467                    finally:
    14681468                        os._exit(0)
    1469            
     1469
    14701470            # Hack to ensure multiprocessing leaves these processes alone
    14711471            multiprocessing.current_process()._children = set()
    14721472
    1473     def dispatch(self): # todo, nthreads=options.nthreads, streaming=False, verbose=options.verbose, debug=options.debug, run_id=run_id
     1473    def dispatch(self):
    14741474        """
    14751475        Run the doctests for the controller's specified sources,
    14761476        by calling :meth:`parallel_dispatch` or :meth:`serial_dispatch`
     
    16441644    def start(self):
    16451645        """
    16461646        Start the worker and close the writing end of the message pipe.
     1647
     1648        TESTS::
     1649
     1650            sage: from sage.doctest.forker import DocTestWorker, DocTestTask
     1651            sage: from sage.doctest.sources import FileDocTestSource
     1652            sage: from sage.doctest.reporting import DocTestReporter
     1653            sage: from sage.doctest.control import DocTestController, DocTestDefaults
     1654            sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     1655            sage: DD = DocTestDefaults()
     1656            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
     1657            sage: W = DocTestWorker(FDS, DD)
     1658            sage: W.start()
     1659            sage: try:
     1660            ....:     os.fstat(W.wmessages)
     1661            ....: except OSError:
     1662            ....:     print "Write end of pipe successfully closed"
     1663            Write end of pipe successfully closed
     1664            sage: W.join()  # Wait for worker to finish
    16471665        """
    16481666        super(DocTestWorker, self).start()
    16491667
     
    16551673        """
    16561674        In the master process, read from the pipe and store the data
    16571675        read in the ``messages`` attribute.
     1676
     1677        .. NOTE::
     1678
     1679            This function may need to be called multiple times in
     1680            order to read all of the messages.
     1681
     1682        EXAMPLES::
     1683
     1684            sage: from sage.doctest.forker import DocTestWorker, DocTestTask
     1685            sage: from sage.doctest.sources import FileDocTestSource
     1686            sage: from sage.doctest.reporting import DocTestReporter
     1687            sage: from sage.doctest.control import DocTestController, DocTestDefaults
     1688            sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     1689            sage: DD = DocTestDefaults(verbose=True,nthreads=2)
     1690            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
     1691            sage: W = DocTestWorker(FDS, DD)
     1692            sage: W.start()
     1693            sage: while W.rmessages is not None:
     1694            ....:     W.read_messages()
     1695            sage: W.join()
     1696            sage: len(W.messages) > 0
     1697            True
    16581698        """
    16591699        # It's absolutely important to execute only one read() system
    16601700        # call, more might block. Assuming that we used pselect()
     
    16721712        the ``result_queue`` and with ``self.output``, the complete
    16731713        contents of ``self.outtmpfile``. Then close the Queue and
    16741714        ``self.outtmpfile``.
     1715
     1716        EXAMPLES::
     1717
     1718            sage: from sage.doctest.forker import DocTestWorker, DocTestTask
     1719            sage: from sage.doctest.sources import FileDocTestSource
     1720            sage: from sage.doctest.reporting import DocTestReporter
     1721            sage: from sage.doctest.control import DocTestController, DocTestDefaults
     1722            sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     1723            sage: DD = DocTestDefaults()
     1724            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
     1725            sage: W = DocTestWorker(FDS, DD)
     1726            sage: W.start()
     1727            sage: W.join()
     1728            sage: W.save_result_output()
     1729            sage: sorted(W.result[1].keys())
     1730            ['cputime', 'err', 'failures', 'walltime']
     1731            sage: len(W.output) > 0
     1732            True
    16751733        """
    16761734        from Queue import Empty
    16771735        try:
     
    16891747        Kill this worker. The first time this is called, use
    16901748        ``SIGHUP``. Subsequent times, use ``SIGKILL``.  Also close the
    16911749        message pipe if it was still open.
     1750
     1751        EXAMPLES::
     1752
     1753            sage: import time
     1754            sage: from sage.doctest.forker import DocTestWorker, DocTestTask
     1755            sage: from sage.doctest.sources import FileDocTestSource
     1756            sage: from sage.doctest.reporting import DocTestReporter
     1757            sage: from sage.doctest.control import DocTestController, DocTestDefaults
     1758            sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     1759            sage: DD = DocTestDefaults()
     1760            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
     1761            sage: W = DocTestWorker(FDS, DD)
     1762            sage: W.start()
     1763            sage: time.sleep(0.05)
     1764            sage: W.killed
     1765            False
     1766            sage: W.kill()
     1767            sage: W.killed
     1768            True
     1769            sage: try:
     1770            ....:     W.kill()
     1771            ....: except OSError:
     1772            ....:     pass
     1773            sage: time.sleep(0.1)
     1774            sage: W.is_alive()
     1775            False
    16921776        """
    16931777        if self.rmessages is not None:
    16941778            os.close(self.rmessages)
     
    17661850
    17671851        OUPUT:
    17681852
    1769         - ``(doctests, runner)`` where ``doctests`` is the number of
    1770           doctests and and ``runner`` is an annotated
    1771           ``SageDocTestRunner`` instance.
     1853        - ``(doctests, result_dict)`` where ``doctests`` is the number of
     1854          doctests and and ``result_dict`` is a dictionary annotated with
     1855          timings and error information.
    17721856
    1773         - Also put ``(doctests, runner)`` onto the ``result_queue``
     1857        - Also put ``(doctests, result_dict)`` onto the ``result_queue``
    17741858          if the latter isn't None.
    17751859
    17761860        EXAMPLES::