mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
hghave: wrap command output matching
This commit is contained in:
parent
6acdd7ff15
commit
9e5343f064
16
tests/hghave
16
tests/hghave
@ -5,11 +5,22 @@ prefixed with "no-", the absence of feature is tested.
|
||||
"""
|
||||
import optparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
tempprefix = 'hg-hghave-'
|
||||
|
||||
def matchoutput(cmd, regexp):
|
||||
"""Return True if cmd executes successfully and its output
|
||||
is matched by the supplied regular expression.
|
||||
"""
|
||||
r = re.compile(regexp)
|
||||
fh = os.popen(cmd)
|
||||
s = fh.read()
|
||||
ret = fh.close()
|
||||
return ret is None and r.search(s)
|
||||
|
||||
def has_symlink():
|
||||
return hasattr(os, "symlink")
|
||||
|
||||
@ -52,10 +63,7 @@ def has_lsprof():
|
||||
return False
|
||||
|
||||
def has_git():
|
||||
fh = os.popen('git --version 2>&1')
|
||||
s = fh.read()
|
||||
ret = fh.close()
|
||||
return ret is None and s.startswith('git version')
|
||||
return matchoutput('git --version 2>&1', r'^git version')
|
||||
|
||||
checks = {
|
||||
"eol-in-paths": (has_eol_in_paths, "end-of-lines in paths"),
|
||||
|
Loading…
Reference in New Issue
Block a user