#8641: "sage -t" should exit with nonzero exit code if doctests fail
----------------------------------------+-----------------------------------
   Reporter:  ddrake                    |       Owner:  ddrake      
       Type:  enhancement               |      Status:  needs_review
   Priority:  minor                     |   Milestone:  sage-5.0    
  Component:  doctest                   |    Keywords:              
     Author:  Dan Drake, John Palmieri  |    Upstream:  N/A         
   Reviewer:                            |      Merged:              
Work_issues:                            |  
----------------------------------------+-----------------------------------

Comment(by ddrake):

 Replying to [comment:12 wjp]:
 > [subprocess.call] does throw a KeyboardInterrupt itself when the called
 program gets a SIGINT, though, so we may have to catch that to execute the
 line
 >
 > {{{
 > failed.append(sage_test_command(F)+" # KeyboardInterrupt")
 > }}}

 Hrm, I'm not sure this is true -- at least on my Ubuntu machine. With the
 most recent version of patch, I changed the bit starting at line 84 of
 sage-test to this:
 {{{
   try:
       err = call(s, shell=True)
       print '%s returned code %s' % (s, err)
   except KeyboardInterrupt:
       print '*****sage-text line 87 caught keyboard interrupt'
       raise
 }}}
 I then ran a doctest (combinat/words/finite_word.py) and in another
 terminal, sent the called process a SIGINT with
 {{{
 kill -2 `ps ax | grep finite_word | grep sage-doctest | grep python | awk
 '{print $1}'
 }}}
 The result is:
 {{{
 sage -t  "devel/sage/sage/combinat/words/finite_word.py"
 KeyboardInterrupt -- interrupted after 3.37038588524 seconds!
 /home/drake/s/sage-4.4.4.alpha0-test/local/bin/sage-doctest
 "devel/sage/sage/combinat/words/finite_word.py" returned code 2
 Aborting further tests.
 }}}
 The "interrupted after 3.370..." is from sage-doctest, line 668, which
 then exits with return code 2. It seems like subprocess.call in this
 instance notes that the process finished, and dutifully passes on the
 return code -- without raising a !KeyboardInterrupt. Then, on line 95 the
 {{{failed.append(sage_test_command(F)+" # KeyboardInterrupt")}}} bit is
 executed and a !KeyboardInterrupt is raised; that causes the "Aborting
 further tests" to be printed.

 If I hit ctrl-c while running the doctest, it gets caught as you would
 expect:
 {{{
 sage -t  "devel/sage/sage/combinat/words/finite_word.py"
 ^CKeyboardInterrupt -- interrupted after 2.75523304939 seconds!
 *****sage-text line 87 caught keyboard interrupt
 Aborting further tests.
 }}}

 What is interesting is, if instead of sending SIGINT to the Python sage-
 doctest process, I send a SIGINT to the *shell* process created by
 subprocess.call, it seems to do nothing -- the doctest runs normally,
 finishes, but the return code is -2; this agrees with
 [http://docs.python.org/library/subprocess.html#subprocess.Popen.returncode
 the Popen returncode documentation]. Then, the entire process exits with
 return code 254, which is a bit strange, but at least it's indicating that
 something strange happened.

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