Opened 13 years ago
Last modified 9 years ago
#5155 closed defect
Fix doctests and methods that want write access to $SAGE_LOCAL — at Version 18
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: | #11920, #11926, #11933 | Stopgaps: |
Description (last modified by )
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 4 -long 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).
On sage-4.7.2.alpha4, this causes:
The following tests failed: sage -t -long devel/sage/sage/modular/hecke/submodule.py # 1 doctests failed sage -t -long devel/sage/sage/modular/abvar/abvar.py # 1 doctests failed sage -t -long devel/sage/sage/lfunctions/sympow.py # 13 doctests failed sage -t -long devel/sage/sage/interfaces/qepcad.py # 3 doctests failed sage -t -long devel/sage/sage/schemes/elliptic_curves/ell_rational_field.py # 17 doctests failed
This seems to be because of:
- Installing an rc file for the experimental package qepcad (in a very odd location
$SAGE_ROOT/local/default.qepcadrc
) - Sympow which needs to create datafiles. This should probably be done in sympow's
spkg-install
instead. See #11920.
Apply:
- 5155_scripts.patch to the scripts repository.
- 5155_qepcad.patch to the Sage library.
Change History (18)
comment:1 Changed 12 years ago by
- Report Upstream set to N/A
- Status changed from new to needs_review
comment:2 Changed 12 years ago by
- Status changed from needs_review to needs_work
comment:3 Changed 12 years ago by
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
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]
comment:5 Changed 12 years ago by
- 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
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(): 636 636 EXAMPLES: 637 637 sage: from sage.interfaces.qepcad import _rewrite_qepcadrc 638 638 sage: _rewrite_qepcadrc() 639 sage: from sage.misc.misc import SAGE_LOCAL640 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] 641 641 'SINGULAR .../local//bin' 642 642 """ 643 643 global _rewrote_qepcadrc 644 644 if _rewrote_qepcadrc: return 645 645 646 SL = sage.misc.misc. SAGE_LOCAL646 SL = sage.misc.misc.DOT_SAGE 647 647 fn = '%s/default.qepcadrc'%SL 648 648 text = \ 649 649 """# 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
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
- Dependencies set to #11926
- Description modified (diff)
- Owner changed from mabshoff to jdemeyer
comment:9 Changed 11 years ago by
- Description modified (diff)
comment:10 Changed 11 years ago by
- Description modified (diff)
comment:11 Changed 11 years ago by
- Description modified (diff)
comment:12 Changed 11 years ago by
- Description modified (diff)
comment:13 Changed 11 years ago by
- Component changed from doctest to scripts
- Description modified (diff)
- Milestone changed from sage-4.7.2 to sage-4.7.3
comment:14 follow-up: ↓ 15 Changed 11 years ago by
- Cc leif added
A few quick comments:
- you have a typo in line 93, "eyactly"
- on line 583,
# optional - qepcad, note "algeraic" [sic]
, this is not the way to format an optional doctest: it will only run if you do "sage -t -optional-only=qepcad,not,algeraic,sic" or something like that. - same on line 1220
For the scripts patch:
- why not apply os.path.abspath to SAGE_ROOT?
comment:15 in reply to: ↑ 14 Changed 11 years ago by
Replying to jhpalmieri:
A few quick comments:
- you have a typo in line 93, "eyactly"
No idea how that happened...
- on line 583,
# optional - qepcad, note "algeraic" [sic]
, this is not the way to format an optional doctest: it will only run if you do "sage -t -optional-only=qepcad,not,algeraic,sic" or something like that.
Very true, thanks!
For the scripts patch:
- why not apply os.path.abspath to SAGE_ROOT?
Because SAGE_ROOT
is already canonicalized by realpath
at the top of that file:
SAGE_ROOT = os.path.realpath(os.environ['SAGE_ROOT'])
comment:16 Changed 11 years ago by
- Dependencies changed from #11926 to #11926, #11933
comment:17 Changed 11 years ago by
Moved the "clean up" part of the qepcad patch to #11933.
comment:18 Changed 11 years ago by
- Dependencies changed from #11926, #11933 to #11920, #11926, #11933
- Description modified (diff)
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:
The changes there look fine in principle, though. So once it's rebased, positive review there, too.