Opened 14 years ago

Last modified 10 years ago

#5155 closed defect

Fix doctests and methods that want write access to $SAGE_LOCAL — at Version 8

Reported by: mabshoff Owned by: jdemeyer
Priority: critical Milestone: sage-5.7
Component: scripts Keywords:
Cc: lftabera, leif Merged in:
Authors: Mike Hansen Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #11926 Stopgaps:

Status badges

Description (last modified by jdemeyer)

All doctests in Sage should pass when they are run as a user that does not have write access to the Sage install. To do that, set SAGE_TESTDIR to some place writable, for example

export SAGE_TESTDIR=$HOME/tmp

and run the doctests on a Sage install that isn't owned by the user:

$ ./sage -tp 6 devel/sage/doc/common devel/sage/doc/de devel/sage/doc/en devel/sage/doc/fr devel/sage/doc/ru devel/sage/sage

Here, we assume that the owner of the Sage install has run Sage at least once (or has applied #11926) and has ran some doctest.

On sage-4.7.2.alpha4, this causes the following failures:

	sage -t -long devel/sage/sage/matrix/matrix2.pyx # 1 doctests failed
	sage -t -long devel/doc/tut/tut.tex # 5 doctests failed
	sage -t -long devel/sage/sage/interfaces/qepcad.py # 2 doctests failed
	sage -t -long devel/sage/sage/plot/plot.py # 6 doctests failed
	sage -t -long devel/sage/sage/databases/database.py # 1 doctests failed
	sage -t -long devel/sage/sage/calculus/calculus.py # 1 doctests failed
	sage -t -long devel/sage/sage/misc/package.py # 1 doctests failed
	sage -t -long devel/sage/sage/gsl/ode.pyx # 4 doctests failed
	sage -t -long devel/sage/sage/server/support.py # 1 doctests failed
	sage -t -long devel/sage/sage/server/notebook/notebook.py # 1 doctests failed
	sage -t -long devel/sage/sage/server/notebook/twist.py # 8 doctests failed
	sage -t -long devel/sage/sage/structure/sage_object.pyx # 6 doctests failed

Change History (8)

comment:1 Changed 13 years ago by mhansen

  • Authors set to Mike Hansen
  • Report Upstream set to N/A
  • Status changed from new to needs_review

comment:2 Changed 13 years ago by jhpalmieri

  • Status changed from needs_review to needs_work

Before applying the patch, I get two doctest failures (with a non-writeable Sage install). Applying the patch "trac_5155.patch" fixes both. So positive review for that.

The scripts patch wasn't necessary to get those tests to pass, and it also doesn't apply cleanly to 4.3.1:

applying /Users/palmieri/Downloads/scripts_5155.patch
patching file sage-doctest
Hunk #1 FAILED at 55
1 out of 1 hunks FAILED -- saving rejects to file sage-doctest.rej
unable to find 'sage-dsage-trial' for patching
1 out of 1 hunks FAILED -- saving rejects to file sage-dsage-trial.rej
patching file sage-maketest
Hunk #1 succeeded at 1 with fuzz 1 (offset -1 lines).
patching file sage-test
Hunk #1 FAILED at 40
1 out of 1 hunks FAILED -- saving rejects to file sage-test.rej
sage-dsage-trial: No such file or directory
abort: patch failed to apply

The changes there look fine in principle, though. So once it's rebased, positive review there, too.

comment:3 Changed 12 years ago by lftabera

Some of the doctest are ok nowadays but there are other new fails. See for example #9965

I can confirm that, with sage 4.5.3 I get the following doctest failures:

sage -t -long "devel/sage/doc/common/builder.py" sage -t -long "devel/sage/sage/interfaces/qepcad.py" sage -t -long "devel/sage/sage/schemes/elliptic_curves/ell_rational_field.py" sage -t -long "devel/sage/sage/modular/hecke/submodule.py" sage -t -long "devel/sage/sage/modular/abvar/abvar.py" sage -t -long "devel/sage/sage/lfunctions/sympow.py"

All except quecad are trying to be solved in #9965

comment:4 Changed 12 years ago by lftabera

qepcad failures

sage -t -long "devel/sage/sage/interfaces/qepcad.py"        
**********************************************************************
File "/opt/SAGE/sage/devel/sage/sage/interfaces/qepcad.py", line 638:
    sage: _rewrite_qepcadrc()
Exception raised:
    Traceback (most recent call last):
      File "/opt/SAGE/sage/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/opt/SAGE/sage/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/opt/SAGE/sage/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_3[3]>", line 1, in <module>
        _rewrite_qepcadrc()###line 638:
    sage: _rewrite_qepcadrc()
      File "/opt/SAGE/sage/local/lib/python/site-packages/sage/interfaces/qepcad.py", line 660, in _rewrite_qepcadrc
        open(fn, 'w').write(text)
    IOError: [Errno 13] Permission denied: '/opt/SAGE/sage/local//default.qepcadrc'
**********************************************************************
File "/opt/SAGE/sage/devel/sage/sage/interfaces/qepcad.py", line 689:
    sage: Qepcad_expect(memcells=100000, logfile=sys.stdout)
Exception raised:
    Traceback (most recent call last):
      File "/opt/SAGE/sage/local/bin/ncadoctest.py", line 1231, in run_one_test
        self.run_one_example(test, example, filename, compileflags)
      File "/opt/SAGE/sage/local/bin/sagedoctest.py", line 38, in run_one_example
        OrigDocTestRunner.run_one_example(self, test, example, filename, compileflags)
      File "/opt/SAGE/sage/local/bin/ncadoctest.py", line 1172, in run_one_example
        compileflags, 1) in test.globs
      File "<doctest __main__.example_6[3]>", line 1, in <module>
        Qepcad_expect(memcells=Integer(100000), logfile=sys.stdout)###line 689:
    sage: Qepcad_expect(memcells=100000, logfile=sys.stdout)
      File "/opt/SAGE/sage/local/lib/python/site-packages/sage/interfaces/qepcad.py", line 692, in __init__
        _rewrite_qepcadrc()
      File "/opt/SAGE/sage/local/lib/python/site-packages/sage/interfaces/qepcad.py", line 660, in _rewrite_qepcadrc
        open(fn, 'w').write(text)
    IOError: [Errno 13] Permission denied: '/opt/SAGE/sage/local//default.qepcadrc'
**********************************************************************
2 items had failures:
   1 of   6 in __main__.example_3
   1 of   4 in __main__.example_6
***Test Failed*** 2 failures.
For whitespace errors, see the file /home/usuario/.sage//tmp/.doctest_qepcad.py
         [1.9 s]
Last edited 10 years ago by jdemeyer (previous) (diff)

comment:5 Changed 12 years ago by lftabera

  • Cc lftabera added
  • Summary changed from Sage 3.3.a3: fix doctests that want write access to $SAGE_LOCAL to Fix doctests and methods that want write access to $SAGE_LOCAL

Another issue, if you compile sage but the very first access of sage is made by a user without write permissions, you get the following error:


| Sage Version 4.5.3, Release Date: 2010-09-04 | | Type notebook() for the GUI, and license() for information. |


Traceback (most recent call last):

File "/opt/SAGE/sage-4.5.3/local/bin/sage-location", line 174, in <module>

t, R = install_moved()

File "/opt/SAGE/sage-4.5.3/local/bin/sage-location", line 18, in install_moved

write_flags_file()

File "/opt/SAGE/sage-4.5.3/local/bin/sage-location", line 82, in write_flags_file

open(flags_file,'w').write(get_flags_info())

IOError: [Errno 13] Permission denied: '/opt/SAGE/sage-4.5.3/local/lib/sage-flags.txt'

comment:6 Changed 11 years ago by jhpalmieri

With Sage 4.7.2.alpha2, I see problems with qepcad and sympow. I think the qepcad problem should be easy to solve, basically as mhansen did before:

  • sage/interfaces/qepcad.py

    diff --git a/sage/interfaces/qepcad.py b/sage/interfaces/qepcad.py
    a b def _rewrite_qepcadrc(): 
    636636    EXAMPLES:
    637637        sage: from sage.interfaces.qepcad import _rewrite_qepcadrc
    638638        sage: _rewrite_qepcadrc()
    639         sage: from sage.misc.misc import SAGE_LOCAL
    640         sage: open('%s/default.qepcadrc'%SAGE_LOCAL).readlines()[-1]
     639        sage: from sage.misc.misc import DOT_SAGE
     640        sage: open('%s/default.qepcadrc'%DOT_SAGE).readlines()[-1]
    641641        'SINGULAR .../local//bin'
    642642    """
    643643    global _rewrote_qepcadrc
    644644    if _rewrote_qepcadrc: return
    645645
    646     SL = sage.misc.misc.SAGE_LOCAL
     646    SL = sage.misc.misc.DOT_SAGE
    647647    fn = '%s/default.qepcadrc'%SL
    648648    text = \
    649649"""# THIS FILE IS AUTOMATICALLY GENERATED -- DO NOT EDIT

Sympow will be harder to deal with, because of how the spkg is written: it tries to write files to SAGE_LOCAL/lib/sympow. See http://trac.sagemath.org/sage_trac/ticket/9703#comment:9 for a possible fix.

I'm attaching a patch to try to deal with the situation when you run Sage for the very first time as a user without write permissions.

Finally, there may be other issues if you compile Sage but don't run it, and then run doctests as a user without write permissions (the first time doctests get run, they might write some files which don't need to be written later). These issues should be fixed, too.

comment:7 Changed 11 years ago by jdemeyer

I'm not sure this patch is a good idea or needed, considering #11926. If the Sage install was moved, it is probably good to bail out with an error if there is no write access.

comment:8 Changed 11 years ago by jdemeyer

  • Dependencies set to #11926
  • Description modified (diff)
  • Owner changed from mabshoff to jdemeyer
Note: See TracTickets for help on using tickets.