Opened 4 years ago

Closed 4 years ago

#25871 closed enhancement (fixed)

Add option to control GC during doctests

Reported by: jdemeyer Owned by:
Priority: major Milestone: sage-8.4
Component: doctest framework Keywords: sagedays@icerm
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 0f2e0e3 (Commits, GitHub, GitLab) Commit: 0f2e0e3865ca813f266334057c086b68e954f08d
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

A new option --gc is proposed to the Sage doctesting framework. It can be used to control garbage collection as follows:

  • --gc=default: Python default
  • --gc=always: run gc.collect() before every single test (unless GC was explicitly disabled)
  • --gc=never: completely disable GC during doctests

I would have found this useful several times for debugging GC-related failures or for more consistent timing of tests.

Note that --gc=always causes a few doctest failures

sage -t src/sage/modular/abvar/abvar_ambient_jacobian.py  # 1 doctest failed
sage -t src/sage/categories/fields.py  # 1 doctest failed
sage -t src/sage/modular/abvar/abvar.py  # 1 doctest failed

but it's not the goal of this ticket to fix these.

Change History (13)

comment:1 Changed 4 years ago by jdemeyer

  • Branch set to u/jdemeyer/add_option_to_control_gc_during_doctests

comment:2 Changed 4 years ago by jdemeyer

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

New commits:

d9a93afAdd option to control GC during doctests

comment:3 Changed 4 years ago by git

  • Commit changed from d9a93af455f01e59128bc081f255dd8c4ec6d0a9 to 1372ec80fd5bea24d555c68f9e6ff4635d4e2b59

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

1372ec8Add option to control GC during doctests

comment:4 Changed 4 years ago by jdemeyer

  • Description modified (diff)

comment:5 Changed 4 years ago by jdemeyer

  • Description modified (diff)

comment:6 Changed 4 years ago by git

  • Commit changed from 1372ec80fd5bea24d555c68f9e6ff4635d4e2b59 to c6f18411651f48f2e1bef59af81f731495611dc1

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

c6f1841Add option to control GC during doctests

comment:7 Changed 4 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to needs_work

Everything seems to work well, and it is definitely a useful feature. (The --gc option is ignored when not running a -t option, which I think is okay. I am just noting this behavior here for the record.)

One thing I think that is missing is to have this this documented in sage --advanced.

comment:8 Changed 4 years ago by git

  • Commit changed from c6f18411651f48f2e1bef59af81f731495611dc1 to 516063796c5d465f4320aa1e1adfb09041893e58

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

ae560ceAdd option to control GC during doctests
5160637Improve doctest options in sage --advanced

comment:9 Changed 4 years ago by jdemeyer

  • Status changed from needs_work to needs_review

comment:10 Changed 4 years ago by tscrim

Sorry to nitpick, but I think for the --advanced, we try to keep it at 70 chars/line, so I would format it as:

                           --gc=GC - control garbarge collection (ALWAYS:
                                     collect garbage before every test;
                                     NEVER: disable gc; DEFAULT: Python
                                     default)

or possibly

                           --gc=GC - control garbarge collection
                                     (ALWAYS: collect garbage before
                                     every test; NEVER: disable gc;
                                     DEFAULT: Python default)

comment:11 Changed 4 years ago by git

  • Commit changed from 516063796c5d465f4320aa1e1adfb09041893e58 to 0f2e0e3865ca813f266334057c086b68e954f08d

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

0f2e0e3Improve doctest options in sage --advanced

comment:12 Changed 4 years ago by tscrim

  • Keywords sagedays@icerm added
  • Status changed from needs_review to positive_review

Thank you.

comment:13 Changed 4 years ago by vbraun

  • Branch changed from u/jdemeyer/add_option_to_control_gc_during_doctests to 0f2e0e3865ca813f266334057c086b68e954f08d
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.