#15120: Fix doctest doctests in git layout.
-------------------------------------------+----------------------------
       Reporter:  robertwb                 |        Owner:
           Type:  bug                      |       Status:  needs_review
       Priority:  major                    |    Milestone:  sage-5.12
      Component:  Doctests                 |   Resolution:
       Keywords:                           |    Merged in:
        Authors:                           |    Reviewers:
Report Upstream:  N/A                      |  Work issues:
         Branch:  u/robertwb/ticket/15120  |       Commit:
   Dependencies:                           |     Stopgaps:
-------------------------------------------+----------------------------

Comment (by SimonKing):

 Trying to accomplish my first git review...

 I see that you replace calls to hg_sage by rather "explicit" calls to
 `subprocess`, such as
 {{{
 #!diff
 diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
 index 9c0ed75..fa35315 100644
 --- a/src/sage/doctest/control.py
 +++ b/src/sage/doctest/control.py
 @@ -453,28 +453,23 @@ class DocTestController(SageObject):
              self.files.extend(glob(opj(SAGE_SRC, 'doc', '[a-z][a-z]')))
              self.options.sagenb = True
          elif self.options.new:
 -            # Get all files changed in the working repo, as well as all
 -            # files in the top Mercurial queue patch.
 -            from sage.misc.hg import hg_sage
 -            out, err = hg_sage('status --rev qtip^', interactive=False,
 debug=False)
 -            if not err:
 -                qtop = hg_sage('qtop', interactive=False,
 debug=False)[0].strip()
 -                self.log("Doctesting files in mq patch " + repr(qtop))
 -            else:  # Probably mq isn't used
 -                out, err = hg_sage('status', interactive=False,
 debug=False)
 -                if not err:
 -                    self.log("Doctesting files changed since last hg
 commit")
 -                else:
 -                    raise RuntimeError("failed to run hg status:\n" +
 err)
 -
 -            for X in out.split('\n'):
 -                tup = X.split()
 -                if len(tup) != 2: continue
 -                c, filename = tup
 -                if c in ['M','A']:
 -                    filename = opj(SAGE_SRC, filename)
 -                    if not skipfile(filename):
 -                        self.files.append(filename)
 +            # Get all files changed in the working repo.
 +            import subprocess
 +            change = subprocess.check_output(["git",
 +                                              "--git-dir=" + SAGE_ROOT +
 "/.git",
 +                                              "--work-tree=" + SAGE_ROOT,
 +                                              "status",
 +                                              "--porcelain"])
 +            self.log("Doctesting files changed since last git commit")
 +            for line in change.split("\n"):
 +                if not line:
 +                    continue
 +                data = line.strip().split(' ')
 +                status, filename = data[0], data[-1]
 +                if (set(status).issubset("MARCU")
 +                    and filename.startswith("src/sage")
 +                    and (filename.endswith(".py") or
 filename.endswith(".pyx"))):
 +                    self.files.append(filename)
          if self.options.sagenb:
              if not self.options.all:
                  self.log("Doctesting the Sage notebook.")
 }}}

 Out of interest: Is "git_sage" already in the making? I.e., will it soon
 be possible to get the status by doing `git_sage("status")`?

--
Ticket URL: <http://trac.sagemath.org/ticket/15120#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to