Rework Spack's Mercurial support (#3834)

* Add tests to mercurial package

* Add support for --insecure with mercurial fetching

* Install man pages and tab-completion scripts

* Add tests and latest version for all deps

* Flake8 fix

* Use certifi module to find CA certificate

* Flake8 fix

* Unset PYTHONPATH when running hg

* svn_fetch should use to svn-test, not hg-test

* Drop Python 3 support in Mercurial

Python 3 support is a work in progress and isn't currently
recommended:

https://www.mercurial-scm.org/wiki/SupportedPythonVersions

* Test both secure and insecure hg fetching

* Test both secure and insecure git and svn fetching
This commit is contained in:
Adam J. Stewart
2017-04-19 20:59:04 -05:00
committed by Todd Gamblin
parent 53763f7698
commit f4858cb7a7
15 changed files with 176 additions and 52 deletions

View File

@@ -808,8 +808,17 @@ def __init__(self, **kwargs):
@property
def hg(self):
""":returns: The hg executable
:rtype: Executable
"""
if not self._hg:
self._hg = which('hg', required=True)
# When building PythonPackages, Spack automatically sets
# PYTHONPATH. This can interfere with hg, which is a Python
# script. Unset PYTHONPATH while running hg.
self._hg.add_default_env('PYTHONPATH', '')
return self._hg
@property
@@ -829,9 +838,15 @@ def fetch(self):
args.append('at revision %s' % self.revision)
tty.msg("Trying to clone Mercurial repository:", self.url, *args)
args = ['clone', self.url]
args = ['clone']
if spack.insecure:
args.append('--insecure')
args.append(self.url)
if self.revision:
args += ['-r', self.revision]
args.extend(['-r', self.revision])
self.hg(*args)

View File

@@ -37,8 +37,15 @@ def type_of_test(request):
return request.param
@pytest.fixture(params=[True, False])
def secure(request):
"""Attempt both secure and insecure fetching"""
return request.param
def test_fetch(
type_of_test,
secure,
mock_git_repository,
config,
refresh_builtin_mock
@@ -62,7 +69,12 @@ def test_fetch(
pkg.versions[ver('git')] = t.args
# Enter the stage directory and check some properties
with pkg.stage:
pkg.do_stage()
try:
spack.insecure = secure
pkg.do_stage()
finally:
spack.insecure = False
assert h('HEAD') == h(t.revision)
file_path = join_path(pkg.stage.source_path, t.file)

View File

@@ -37,8 +37,15 @@ def type_of_test(request):
return request.param
@pytest.fixture(params=[True, False])
def secure(request):
"""Attempt both secure and insecure fetching"""
return request.param
def test_fetch(
type_of_test,
secure,
mock_hg_repository,
config,
refresh_builtin_mock
@@ -62,7 +69,12 @@ def test_fetch(
pkg.versions[ver('hg')] = t.args
# Enter the stage directory and check some properties
with pkg.stage:
pkg.do_stage()
try:
spack.insecure = secure
pkg.do_stage()
finally:
spack.insecure = False
assert h() == t.revision
file_path = join_path(pkg.stage.source_path, t.file)

View File

@@ -33,12 +33,19 @@
@pytest.fixture(params=['default', 'rev0'])
def type_of_test(request):
"""Returns one of the test type available for the mock_hg_repository"""
"""Returns one of the test type available for the mock_svn_repository"""
return request.param
@pytest.fixture(params=[True, False])
def secure(request):
"""Attempt both secure and insecure fetching"""
return request.param
def test_fetch(
type_of_test,
secure,
mock_svn_repository,
config,
refresh_builtin_mock
@@ -56,13 +63,18 @@ def test_fetch(
t = mock_svn_repository.checks[type_of_test]
h = mock_svn_repository.hash
# Construct the package under test
spec = Spec('hg-test')
spec = Spec('svn-test')
spec.concretize()
pkg = spack.repo.get(spec, new=True)
pkg.versions[ver('hg')] = t.args
pkg.versions[ver('svn')] = t.args
# Enter the stage directory and check some properties
with pkg.stage:
pkg.do_stage()
try:
spack.insecure = secure
pkg.do_stage()
finally:
spack.insecure = False
assert h() == t.revision
file_path = join_path(pkg.stage.source_path, t.file)