[PATCH default-tests-fix] test: protect the run-tests.py --json test behind an hghave rule
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Thu Sep 18 18:50:58 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1411065827 25200
# Thu Sep 18 11:43:47 2014 -0700
# Node ID fa5cfb6d0b03d9fd471b920d9f5fe0ac358cdbb1
# Parent 48791c2bea1ceda4e4f28bc11651e281d636ce1a
test: protect the run-tests.py --json test behind an hghave rule
We add a rules to detect availability of a json module and skip if json is not
available.
diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -279,10 +279,22 @@ def has_pygments():
@check("python243", "python >= 2.4.3")
def has_python243():
return sys.version_info >= (2, 4, 3)
+ at check("json", "some json module available")
+def has_json():
+ try:
+ if sys.version_info < (2, 7):
+ import simplejson as json
+ else:
+ import json
+ json.dumps
+ return True
+ except ImportError:
+ return False
+
@check("outer-repo", "outer repo")
def has_outer_repo():
# failing for other reasons than 'no repo' imply that there is a repo
return not matchoutput('hg root 2>&1',
r'abort: no repository found', True)
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -367,10 +367,12 @@ Missing skips or blacklisted skips don't
ss
Skipped test-bogus.t: Doesn't exist
Skipped test-failure.t: blacklisted
# Ran 0 tests, 2 skipped, 0 warned, 0 failed.
+#if json
+
test for --json
==================
$ $TESTDIR/run-tests.py --with-hg=`which hg` --json
@@ -404,5 +406,7 @@ test for --json
"test-success.t": [\{] (re)
"result": "success",
"time": "\s*[\d\.]{5}" (re)
}
} (no-eol)
+
+#endif
More information about the Mercurial-devel
mailing list