testing: add hghave test for Docker
authorGregory Szorc <gps@mozilla.com>
Fri, 03 Oct 2014 17:52:52 -0700
changeset 359560 d7462fb54f976f1324f059ad19ce9e89b9d245e5
parent 359559 7b75ea937109d132a1cf65d3811a5a1f4eb47565
child 359561 9df146fb7b9e0ac283668553a33de3063c76f7a7
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
testing: add hghave test for Docker We can now use "#require docker" in .t tests to look for Docker.
testing/hghave.py
--- a/testing/hghave.py
+++ b/testing/hghave.py
@@ -20,16 +20,24 @@ import sys
 if 'REPO_ROOT' not in globals():
     print('hghave.py included wrong. please set REPO_ROOT variable in calling script')
     sys.exit(1)
 
 # We import Mercurial's own ``hghave.py`` so we can declare our own checks.
 HGHAVE_PY = os.path.join(REPO_ROOT, 'pylib', 'mercurial-support', 'hghave.py')
 execfile(HGHAVE_PY)
 
+# Define custom checks for our environment.
+@check('docker', 'We can talk to Docker')
+def has_docker():
+    import docker
+    c = docker.Client(base_url=os.environ.get('DOCKER_HOST', None))
+    c.containers()
+    return True
+
 # Now we reimplement the command line syntax of the CLI hghave script.
 failures = 0
 
 def error(msg):
     global failures
     sys.stderr.write('%s\n' % msg)
     failures += 1