summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2017-04-19 20:59:04 -0500
committerTodd Gamblin <tgamblin@llnl.gov>2017-04-19 18:59:04 -0700
commitf4858cb7a7dfbc111a95580495a5c2ce3ab69ea8 (patch)
tree8baa1c5437b0f23800545789f78e62868096a701 /lib
parent53763f76985cd1ba0812376d536600e560d3a070 (diff)
downloadspack-f4858cb7a7dfbc111a95580495a5c2ce3ab69ea8.tar.gz
spack-f4858cb7a7dfbc111a95580495a5c2ce3ab69ea8.tar.bz2
spack-f4858cb7a7dfbc111a95580495a5c2ce3ab69ea8.tar.xz
spack-f4858cb7a7dfbc111a95580495a5c2ce3ab69ea8.zip
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
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/fetch_strategy.py19
-rw-r--r--lib/spack/spack/test/git_fetch.py14
-rw-r--r--lib/spack/spack/test/hg_fetch.py14
-rw-r--r--lib/spack/spack/test/svn_fetch.py20
4 files changed, 59 insertions, 8 deletions
diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py
index 38752b3fc1..855b2f9379 100644
--- a/lib/spack/spack/fetch_strategy.py
+++ b/lib/spack/spack/fetch_strategy.py
@@ -808,8 +808,17 @@ class HgFetchStrategy(VCSFetchStrategy):
@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 @@ class HgFetchStrategy(VCSFetchStrategy):
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)
diff --git a/lib/spack/spack/test/git_fetch.py b/lib/spack/spack/test/git_fetch.py
index 3bd998c5c2..ef531ef65f 100644
--- a/lib/spack/spack/test/git_fetch.py
+++ b/lib/spack/spack/test/git_fetch.py
@@ -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)
diff --git a/lib/spack/spack/test/hg_fetch.py b/lib/spack/spack/test/hg_fetch.py
index 71e4693c56..29a6eef561 100644
--- a/lib/spack/spack/test/hg_fetch.py
+++ b/lib/spack/spack/test/hg_fetch.py
@@ -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)
diff --git a/lib/spack/spack/test/svn_fetch.py b/lib/spack/spack/test/svn_fetch.py
index 962a150909..69d675fe3c 100644
--- a/lib/spack/spack/test/svn_fetch.py
+++ b/lib/spack/spack/test/svn_fetch.py
@@ -33,12 +33,19 @@ from spack.version import ver
@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)