Opened 10 years ago

Closed 9 years ago

#9163 closed defect (fixed)

Doctest error in expect.py on Cygwin and OS X

Reported by: was Owned by: jdemeyer
Priority: blocker Milestone: sage-4.6.1
Component: interfaces Keywords: cygwin osx expect doctest
Cc: SimonKing Merged in: sage-4.6.1.rc0
Authors: Jeroen Demeyer Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by jdemeyer)

On Cygwin and on OS X 10.6, the doctest sage/interfaces/expect.py fails:

sage -t  "devel/sage/sage/interfaces/expect.py"             
**********************************************************************
File "/home/wstein/sage-4.4.3/devel/sage/sage/interfaces/expect.py", line 808:
    sage: print sage0.eval("alarm(1); singular._expect_expr('1')")
Expected:
    Control-C pressed.  Interrupting Singular. Please wait a few seconds...
    ...
    KeyboardInterrupt: computation timed out because alarm was set for 1 seconds
Got:
    ---------------------------------------------------------------------------
    KeyboardInterrupt                         Traceback (most recent call last)
    <BLANKLINE>
    /home/wstein/sage-4.4.3/data/extcode/sage/<ipython console> in <module>()
    <BLANKLINE>
    /home/wstein/sage-4.4.3/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in _expect_expr(self, expr, timeout)
        815             expr = self._prompt_wait
        816         if self._expect is None:
    --> 817             self._start()
        818         try:
        819             if timeout:
    <BLANKLINE>
    /home/wstein/sage-4.4.3/local/lib/python2.6/site-packages/sage/interfaces/singular.pyc in _start(self, alt_message)
        373         """
        374         self.__libs = []
    --> 375         Expect._start(self, alt_message)
        376         # Load some standard libraries.
        377         self.lib('general')   # assumed loaded by misc/constants.py
    <BLANKLINE>
    /home/wstein/sage-4.4.3/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc in _start(self, alt_message, block_during_init)
        447                 c = 'sage-native-execute  ssh %s "nohup sage -cleaner"  &'%self._server
        448                 os.system(c)
    --> 449             self._expect = pexpect.spawn(cmd, logfile=self.__logfile)
        450             if self._do_cleaner():
        451                 cleaner.cleaner(self._expect.pid, cmd)
    <BLANKLINE>
    /home/wstein/sage-4.4.3/local/lib/python2.6/site-packages/pexpect.pyc in __init__(self, command, args, timeout, maxread, searchwindowsize, logfile)
        331 
        332         self.name = '<' + ' '.join (self.args) + '>'
    --> 333         self.__spawn()
        334 
        335     def __del__(self):
    <BLANKLINE>
    /home/wstein/sage-4.4.3/local/lib/python2.6/site-packages/pexpect.pyc in __spawn(self)
        399 
        400         try:
    --> 401             self.pid, self.child_fd = pty.fork()
        402         except OSError, e:
        403             raise ExceptionPexpect('Pexpect: pty.fork() failed: ' + str(e))
    <BLANKLINE>
    /home/wstein/sage-4.4.3/local/lib/python/pty.pyc in fork()
         93 
         94     try:
    ---> 95         pid, fd = os.forkpty()
         96     except (AttributeError, OSError):
         97         pass
    <BLANKLINE>
    /home/wstein/sage-4.4.3/local/lib/python2.6/site-packages/sage/misc/misc.pyc in __mysig(a, b)
       1690 __alarm_time=0
       1691 def __mysig(a,b):
    -> 1692     raise KeyboardInterrupt, "computation timed out because alarm was set for %s seconds"%__alarm_time
       1693 
       1694 def alarm(seconds):
    <BLANKLINE>
    KeyboardInterrupt: computation timed out because alarm was set for 1 seconds
**********************************************************************
1 items had failures:
   1 of  10 in __main__.example_15
***Test Failed*** 1 failures.

Attachments (1)

9163_expect_expr.patch (1.8 KB) - added by jdemeyer 9 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 9 years ago by jdemeyer

  • Component changed from cygwin to interfaces
  • Description modified (diff)
  • Keywords cygwin osx expect doctest added
  • Owner changed from tbd to was
  • Summary changed from cygwin: output of a subtle test in expect.py differs slightly on cygwin to Doctest error in expect.py on Cygwin and OS X

comment:2 Changed 9 years ago by jdemeyer

  • Priority changed from major to blocker

comment:3 Changed 9 years ago by mpatel

  • Cc SimonKing added

Does this happen because the interface might be slow to start up?

Should we move the lines

        if self._expect is None:
            self._start()

in sage.interfaces.expect.Expect._expect_expr to inside its outermost try block?

comment:4 Changed 9 years ago by mpatel

Or remove "Control-C pressed. Interrupting Singular. Please wait a few seconds..." from the expected output?

comment:5 Changed 9 years ago by jdemeyer

  • Owner changed from was to jdemeyer

The problem is with the Singular interface, see #10476.

comment:6 Changed 9 years ago by jdemeyer

  • Authors set to Jeroen Demeyer
  • Status changed from new to needs_review

comment:7 Changed 9 years ago by jdemeyer

Apart from this, expect.py is a huge mess...

comment:8 Changed 9 years ago by jdemeyer

  • Status changed from needs_review to needs_work

Changed 9 years ago by jdemeyer

comment:9 Changed 9 years ago by jdemeyer

  • Status changed from needs_work to needs_review

comment:10 Changed 9 years ago by mhansen

I cannot test this on Cygwin since I don't have a build right now. I do have one close to completion, but it fails due to #10247.

comment:11 Changed 9 years ago by jdemeyer

  • Merged in set to sage-4.6.1.rc0

comment:12 Changed 9 years ago by vbraun

  • Status changed from needs_review to positive_review

I agree that Singular isn't a good test for the expect interfaces since it is quite finicky with being interrupted/restarting. Improving the Singular interface will be pursued in #10247. In the meantime, positive review for this ticket.

comment:13 Changed 9 years ago by jdemeyer

  • Resolution set to fixed
  • Reviewers set to Volker Braun
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.