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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

valentin.gatienbaron (Valentin Gatien-Baron)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This test has been failing on Windows since 0af56d3ee24c <https://phab.mercurial-scm.org/rHG0af56d3ee24c2b803b8393b5bad4abcd1daa3e78>
  introduced the `hg files` invocation. Specifically, Windows seems
  to be choking on special characters in the fileset pattern. I
  believe at least \n and > were causing issues.
 
  I attempted various incantations to make the Windows command line
  parser accept the fileset but couldn't get anything working.
  I declared bankruptcy and just reimplemented the grepping code
  in Python.
 
  After this change, the test now passes on Windows again.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS

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()
 



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

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

valentin.gatienbaron (Valentin Gatien-Baron)
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

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()
 



To: indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel