Patchwork D9150: tests: skip doctests if not running from a hg repo

login
register
mail settings
Submitter phabricator
Date Oct. 5, 2020, 8:16 p.m.
Message ID <differential-rev-PHID-DREV-fkviafa5d7j3y6hjhvpz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47379/
State Superseded
Headers show

Comments

phabricator - Oct. 5, 2020, 8:16 p.m.
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-doctest.py

CHANGE DETAILS




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, 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
@@ -4,7 +4,7 @@ 
 from __future__ import print_function
 
 import doctest
-import os
+import os.path
 import re
 import subprocess
 import sys
@@ -72,6 +72,9 @@ 
 
 cwd = os.path.dirname(os.environ["TESTDIR"])
 
+if not os.path.isdir(os.path.join(cwd, ".hg")):
+    sys.exit(0)
+
 files = subprocess.check_output(
     "hg files --print0 \"%s\"" % fileset, shell=True, cwd=cwd,
 ).split(b'\0')