Patchwork D8343: tests: perform grep manually in test-doctest.py

login
register
mail settings
Submitter phabricator
Date April 1, 2020, 7:09 p.m.
Message ID <156cb5a0ade144c027f6ab62e4d52338@localhost.localdomain>
Download mbox | patch
Permalink /patch/45982/
State Not Applicable
Headers show

Comments

phabricator - April 1, 2020, 7:09 p.m.
Closed by commit rHG15aef805619d: tests: perform grep manually in test-doctest.py (authored by indygreg).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8343?vs=20916&id=20953

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8343/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8343

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -68,20 +68,26 @@ 
     'tests.test-url': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
 }
 
-doctest_indicator = '\n\\s*>>> '
-fileset = 'set:(**.py and grep("%s"))' % doctest_indicator
+fileset = 'set:(**.py)'
+
+cwd = os.path.dirname(os.environ["TESTDIR"])
 
 files = subprocess.check_output(
-    "hg files --print0 '%s'" % fileset,
-    shell=True,
-    cwd=os.path.dirname(os.environ['TESTDIR']),
+    "hg files --print0 \"%s\"" % fileset, shell=True, cwd=cwd,
 ).split(b'\0')
 
+if sys.version_info[0] >= 3:
+    cwd = os.fsencode(cwd)
+
 mods_tested = set()
 for f in files:
     if not f:
         continue
 
+    with open(os.path.join(cwd, f), "rb") as fh:
+        if not re.search(br'\n\s*>>>', fh.read()):
+            continue
+
     if ispy3:
         f = f.decode()