#12415: Update doctesting framework
-------------------------------------------------------------------------------------------------------------------------+
       Reporter:  robertwb                                                      
                                         |         Owner:  mvngu       
           Type:  enhancement                                                   
                                         |        Status:  needs_review
       Priority:  major                                                         
                                         |     Milestone:  sage-5.1    
      Component:  doctest                                                       
                                         |    Resolution:              
       Keywords:                                                                
                                         |   Work issues:              
Report Upstream:  N/A                                                           
                                         |     Reviewers:              
        Authors:                                                                
                                         |     Merged in:              
   Dependencies:  #13147,#13146, #13145, #12723, #12392, #12393, #12395, 
#12396, #12397, #12381, #12382, #12383, #12384  |      Stopgaps:              
-------------------------------------------------------------------------------------------------------------------------+

Comment (by jhpalmieri):

 I would suggest the following two changes: for the scripts repo:
 {{{
 #!diff
 diff --git a/sage-runtests b/sage-runtests
 --- a/sage-runtests
 +++ b/sage-runtests
 @@ -5,7 +5,7 @@ import optparse, os, sys
  if __name__ == "__main__":
      parser = optparse.OptionParser()

 -    parser.add_option("-p", "--nthreads", type=int, default=1,
 metavar="N", help="tests in parallel using N threads with 0 interpreted as
 minimum(8, cpu_count())")
 +    parser.add_option("-p", "--nthreads", type="string", default=1,
 metavar="N", help="tests in parallel using N threads with 0 interpreted as
 minimum(8, cpu_count())")
      parser.add_option("--serial", action="store_true", default=False,
 help="run tests in a single process in series")
      parser.add_option("--timeout", type=int, default=-1, help="timeout
 (in seconds) for doctesting one file")
      parser.add_option("-a", "--all", action="store_true", default=False,
 help="test all files in the Sage library")
 @@ -49,7 +49,20 @@ if __name__ == "__main__":
      parser.add_option("--stats_path", "--stats-path",
 default=os.path.join(os.path.expanduser("~/.sage/timings2.json")), \
                            help="path to a json dictionary for the latest
 run storing a timing for each file")

 +    options, args = parser.parse_args()
 +    try:
 +        options.nthreads = int(options.nthreads)
 +    except ValueError:
 +        args.insert(0, options.nthreads.strip())
 +        options.nthreads = 0
 +
 +    if options.nthreads == 0:
 +        try:
 +            options.nthreads =
 int(os.environ['SAGE_NUM_THREADS_PARALLEL'])
 +        except KeyError:
 +            options.nthreads = 1
 +
      from sage.doctest.control import DocTestController
 -    DC = DocTestController(*parser.parse_args())
 +    DC = DocTestController(options, args)
      err = DC.run()
      sys.exit(err)
 }}}
 and for the Sage library:
 {{{
 #!diff
 diff --git a/sage/doctest/control.py b/sage/doctest/control.py
 --- a/sage/doctest/control.py
 +++ b/sage/doctest/control.py
 @@ -433,8 +433,9 @@ class DocTestController(SageObject):
              else:
                  nother += 1
          if nfiles + ndbsources + nother:
 -            self.log("Doctesting %s."%(", ".join((["%s file%s"%(nfiles,
 "s" if nfiles > 1 else "")] if nfiles else []) +
 -                                                 (["%s other
 sources"%nother] if nother else []))))
 +            self.log("Doctesting %s"%(", ".join((["%s file%s"%(nfiles,
 "s" if nfiles > 1 else "")] if nfiles else []) +
 +                                                 (["%s other
 sources"%nother] if nother else [])))
 +                + " using %s threads."%self.options.nthreads if
 self.options.nthreads > 1 else ".")
              self.reporter = DocTestReporter(self)
              self.dispatcher = DocTestDispatcher(self)
              try:
 }}}

 Or something like that. I guess you should also print the number of
 threads when you print "Doctesting entire Sage library.", etc.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12415#comment:26>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to