Repair `sage -t --valgrind`
As noted in https://github.com/sagemath/sage/pull/36046#issuecomment-1676833196, sage -t --valgrind does not work because it instruments the wrong process.
As part of the fix, we move the contents of src/bin/sage-runtests to src/bin/sage/doctest/__main__.py so that the doctester can be invoked as sage -python -m sage.doctest.
We also arrange for sage -t --valgrind to use the suppressions file added in #36046.
:memo: Checklist
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.
:hourglass: Dependencies
Works fine with my current testing workflow (no --valgrind). However, using --valgrind doesn't work:
> sage -t --installed --valgrind
too many failed tests, not using stored timings
exec valgrind --tool=memcheck --leak-resolution=high --leak-check=full --num-callers=25 --suppressions=/usr/lib/python3.11/site-packages/sage/ext_data/valgrind/pyalloc.supp --suppressions=/usr/lib/python3.11/site-packages/sage/ext_data/valgrind/sage.supp --suppressions=/usr/lib/python3.11/site-packages/sage/ext_data/valgrind/sage-additional.supp --suppressions=/usr/lib/python3.11/site-packages/sage/ext_data/valgrind/valgrind-python.supp --log-file=/home/antonio/.sage/valgrind/sage-memcheck.%p /usr/bin/python -m sage.doctest --serial --timeout=172800 --stats_path=/home/antonio/.sage/timings2.json --optional=pip,sage
either use --new, --all, --installed, or some filenames
(which is nonsense, since I did pass --installed)
Thanks for testing! I'll investigate.
This quick fix should take care of --installed, but there is a whole list of other options that would also need to be handled.
This quick fix should take care of
--installed, but there is a whole list of other options that would also need to be handled.
Since --all is disallowed, shouldn't --installed be disallowed too? Since usually one does have the entire library installed, not just one file.
Since
--allis disallowed, shouldn't--installedbe disallowed too?
I've removed this check now. I think it was poorly motivated. Note that one could already pass multiple filenames on the command line.
there is a whole list of other options that would also need to be handled.
I've added them all now.
Documentation preview for this PR (built with commit 01ce6d76b9747cb8e6dd753b26a47ef7f515b495; changes) is ready! :tada: This preview will update shortly after each push to this PR.
I get
$ sage -t --valgrind src/sage/coding/ag_code_decoders.pyx
exec valgrind --tool=memcheck --leak-resolution=high --leak-check=full --num-callers=25 --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/pyalloc.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/sage.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/sage-additional.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/valgrind-python.supp --log-file=/home/kwankyu/.sage/valgrind/sage-memcheck.%p /home/kwankyu/GitHub/sage-dev/local/var/lib/sage/venv-python3.12/bin/python3 -m sage.doctest --serial --timeout=172800 --warn_long=46.83061857819557 --random_seed=106105322697099798603050462338239531047 --global_iterations=1 --file_iterations=1 --optional=debian,pip,sage,sage_spkg src/sage/coding/ag_code_decoders.pyx
usage: sage -t [options] filenames
__main__.py: error: unrecognized arguments: --warn_long=46.83061857819557 --random_seed=106105322697099798603050462338239531047
I get
$ sage -t --valgrind src/sage/coding/ag_code_decoders.pyx exec valgrind --tool=memcheck --leak-resolution=high --leak-check=full --num-callers=25 --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/pyalloc.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/sage.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/sage-additional.supp --suppressions=/home/kwankyu/GitHub/sage-dev/src/sage/ext_data/valgrind/valgrind-python.supp --log-file=/home/kwankyu/.sage/valgrind/sage-memcheck.%p /home/kwankyu/GitHub/sage-dev/local/var/lib/sage/venv-python3.12/bin/python3 -m sage.doctest --serial --timeout=172800 --warn_long=46.83061857819557 --random_seed=106105322697099798603050462338239531047 --global_iterations=1 --file_iterations=1 --optional=debian,pip,sage,sage_spkg src/sage/coding/ag_code_decoders.pyx usage: sage -t [options] filenames __main__.py: error: unrecognized arguments: --warn_long=46.83061857819557 --random_seed=106105322697099798603050462338239531047
Is this fixed?
I should learn to set a "needs work" PR back to "draft" before rebasing it
Ready? As far as I can see, it is working well.
Thanks!
I'm getting
**********************************************************************
File "src/sage/doctest/__main__.py", line 38, in sage.doctest.__main__._get_optional_defaults
Failed example:
DA = DocTestDefaults(runtest_default=True, **D); DA
Expected:
DocTestDefaults(abspath=False, file_iterations=0, global_iterations=0,
optional='sage,optional', random_seed=None,
stats_path='.../timings2.json')
Got:
DocTestDefaults(abspath=False, file_iterations=0, global_iterations=0, optional='sage,optional', stats_path='/var/lib/buildbot/worker/sage_git/dot_sage/timings2.json')
**********************************************************************
Do you set doctester-related env variables or pass options to sage -t on buildbot?
Buildbot sets SAGE_DOCTEST_RANDOM_SEED=0
Thanks, I'll investigate