summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2019-06-21 16:56:38 -0700
committerGitHub <noreply@github.com>2019-06-21 16:56:38 -0700
commit1ae03b327cd8297cdf1067c03ec833d739d36d8b (patch)
tree127b155aedee032ba9bab5cfc835d18aebfe832d /lib
parent98d21193ff6da7545894bd5980ef98748a512cce (diff)
downloadspack-1ae03b327cd8297cdf1067c03ec833d739d36d8b.tar.gz
spack-1ae03b327cd8297cdf1067c03ec833d739d36d8b.tar.bz2
spack-1ae03b327cd8297cdf1067c03ec833d739d36d8b.tar.xz
spack-1ae03b327cd8297cdf1067c03ec833d739d36d8b.zip
Use Stage.archive_file to access non-expanded download (#11817)
Fixes #11816 Allow packages to refer to non-expanded downloads (e.g. a single script) using Stage.archive_file. This addresses a regression from #11688 and adds a unit test for it.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/stage.py16
-rw-r--r--lib/spack/spack/test/stage.py13
2 files changed, 25 insertions, 4 deletions
diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py
index 6d5848da38..4249ec6f85 100644
--- a/lib/spack/spack/stage.py
+++ b/lib/spack/spack/stage.py
@@ -296,13 +296,21 @@ class Stage(object):
def expected_archive_files(self):
"""Possible archive file paths."""
paths = []
+
+ fnames = []
+ expanded = True
if isinstance(self.default_fetcher, fs.URLFetchStrategy):
- paths.append(os.path.join(
- self.path, os.path.basename(self.default_fetcher.url)))
+ expanded = self.default_fetcher.expand_archive
+ fnames.append(os.path.basename(self.default_fetcher.url))
if self.mirror_path:
- paths.append(os.path.join(
- self.path, os.path.basename(self.mirror_path)))
+ fnames.append(os.path.basename(self.mirror_path))
+
+ paths.extend(os.path.join(self.path, f) for f in fnames)
+ if not expanded:
+ # If the download file is not compressed, the "archive" is a
+ # single file placed in Stage.source_path
+ paths.extend(os.path.join(self.source_path, f) for f in fnames)
return paths
diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py
index 908771de90..9f5e7363f5 100644
--- a/lib/spack/spack/test/stage.py
+++ b/lib/spack/spack/test/stage.py
@@ -465,6 +465,19 @@ class TestStage(object):
check_setup(stage, None, archive)
check_destroy(stage, None)
+ @pytest.mark.usefixtures('tmpdir_for_stage')
+ def test_noexpand_stage_file(
+ self, mock_stage_archive, mock_noexpand_resource):
+ """When creating a stage with a nonexpanding URL, the 'archive_file'
+ property of the stage should refer to the path of that file.
+ """
+ test_noexpand_fetcher = spack.fetch_strategy.from_kwargs(
+ url='file://' + mock_noexpand_resource, expand=False)
+ with Stage(test_noexpand_fetcher) as stage:
+ stage.fetch()
+ stage.expand_archive()
+ assert os.path.exists(stage.archive_file)
+
@pytest.mark.disable_clean_stage_check
@pytest.mark.usefixtures('tmpdir_for_stage')
def test_composite_stage_with_noexpand_resource(