Patchwork D8162: hghave: add a `rust` keyword to detect the use of compiled rust code

login
register
mail settings
Submitter phabricator
Date Feb. 26, 2020, 5:37 p.m.
Message ID <differential-rev-PHID-DREV-ldm5qzuk5zfpgmaihidt-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45343/
State Superseded
Headers show

Comments

phabricator - Feb. 26, 2020, 5:37 p.m.
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The content of some on disk cache can varies when using rust (because it is
  faster to do so in the rust variant). So we need to be able to detect this case
  for some test.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/hghave.py

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/hghave.py b/tests/hghave.py
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -332,6 +332,17 @@ 
     return gethgversion() >= (int(major), int(minor))
 
 
+@check("rust", "Using the Rust extensions")
+def has_rust():
+    """Check is the mercurial currently running is using some rust code"""
+    cmd = 'hg debuginstall --quiet 2>&1'
+    match = br'checking module policy \(([^)]+)\)'
+    policy = matchoutput(cmd, match)
+    if not policy:
+        return False
+    return 'rust' in policy.group(1)
+
+
 @check("hg08", "Mercurial >= 0.8")
 def has_hg08():
     if checks["hg09"][0]():