summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
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)