#8641: "sage -t" should exit with nonzero exit code if doctests fail
---------------------------+------------------------------------------------
   Reporter:  ddrake       |       Owner:  tbd       
       Type:  enhancement  |      Status:  needs_work
   Priority:  minor        |   Milestone:            
  Component:  doctest      |    Keywords:            
     Author:               |    Upstream:  N/A       
   Reviewer:               |      Merged:            
Work_issues:               |  
---------------------------+------------------------------------------------
Changes (by ddrake):

  * status:  needs_review => needs_work


Comment:

 Your patch seems to work as far as hitting Ctrl-C goes, but if doctesting
 more than one file, if doctests fail, the entire run fails:
 {{{
 Traceback (most recent call last):
   File "/scratch/sage-4.3.5/local/bin/sage-test", line 177, in <module>
     err = test_file(F)
   File "/scratch/sage-4.3.5/local/bin/sage-test", line 125, in test_file
     err = test(F, 'doctest ' + opts + extra_opts)
   File "/scratch/sage-4.3.5/local/bin/sage-test", line 84, in test
     err = check_call(s, shell=True)
   File "/scratch/sage-4.3.5/local/lib/python/subprocess.py", line 488, in
 check_call
     raise CalledProcessError(retcode, cmd)
 subprocess.CalledProcessError: Command '/scratch/sage-4.3.5/local/bin
 /sage-doctest  "devel/sage/sage/combinat/tableau.py"' returned non-zero
 exit status 100
 }}}
 I think we want subprocess.call, not check_call; that will allow us to
 pass the exit code back up if we want to; "call" returns the exit code,
 but check_call either returns or raises CalledProcessError. Of course, if
 you like, we can catch the exception and just use that information.

 Also, I think we can avoid the shell=True bit, since our command line is
 so simple: just do
 {{{
 err = call([os.path.join(SAGE_ROOT, 'local', 'bin', 'sage-%s' % cmd), F])
 }}}
 and, on line 127, change 'doctest ' (note the space) to 'doctest'.

 Finally, if using the subprocess module, I think we get the genuine return
 code and there's no need for any "err = err // 256" business.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8641#comment:7>
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