Patchwork [7,of,8] hghave: add check for zstd support

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 11, 2016, 9:23 a.m.
Message ID <2628b96b3884024e3c05.1478856219@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17474/
State Accepted
Headers show

Comments

Gregory Szorc - Nov. 11, 2016, 9:23 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1478849921 28800
#      Thu Nov 10 23:38:41 2016 -0800
# Node ID 2628b96b3884024e3c0552303d71bdd9fbd99a71
# Parent  45801e65f33949e6663ebfff651cb78d01afcc3e
hghave: add check for zstd support

Not all configurations will support zstd. Add a check so we can
conditionalize tests.

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -610,3 +610,12 @@  def has_hypothesis():
 @check("unziplinks", "unzip(1) understands and extracts symlinks")
 def unzip_understands_symlinks():
     return matchoutput('unzip --help', br'Info-ZIP')
+
+@check("zstd", "zstd Python module available")
+def has_zstd():
+    try:
+        import mercurial.zstd
+        mercurial.zstd.__version__
+        return True
+    except ImportError:
+        return False