Improve mock_archive versatility; Remove unwanted ALLOWED_ARCHIVE_TYPES. (#12513)
mock_archive can now take multiple extension / tar option pairs (default matches old behavior). url_fetch.test_fetch tests more archive types. compression.EXTS split into EXTS and NOTAR_EXTS to avoid unwanted, non-meaningful combinatoric extensions such as .tar.tbz2.
This commit is contained in:
parent
00b02fd234
commit
7f8fe11e4d
@ -585,8 +585,8 @@ def _impl(filename):
|
|||||||
##########
|
##########
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session', params=[('.tar.gz', 'z')])
|
||||||
def mock_archive(tmpdir_factory):
|
def mock_archive(request, tmpdir_factory):
|
||||||
"""Creates a very simple archive directory with a configure script and a
|
"""Creates a very simple archive directory with a configure script and a
|
||||||
makefile that installs to a prefix. Tars it up into an archive.
|
makefile that installs to a prefix. Tars it up into an archive.
|
||||||
"""
|
"""
|
||||||
@ -615,8 +615,10 @@ def mock_archive(tmpdir_factory):
|
|||||||
|
|
||||||
# Archive it
|
# Archive it
|
||||||
with tmpdir.as_cwd():
|
with tmpdir.as_cwd():
|
||||||
archive_name = '{0}.tar.gz'.format(spack.stage._source_path_subdir)
|
archive_name = '{0}{1}'.format(spack.stage._source_path_subdir,
|
||||||
tar('-czf', archive_name, spack.stage._source_path_subdir)
|
request.param[0])
|
||||||
|
tar('-c{0}f'.format(request.param[1]), archive_name,
|
||||||
|
spack.stage._source_path_subdir)
|
||||||
|
|
||||||
Archive = collections.namedtuple('Archive',
|
Archive = collections.namedtuple('Archive',
|
||||||
['url', 'path', 'archive_file',
|
['url', 'path', 'archive_file',
|
||||||
|
@ -45,6 +45,11 @@ def test_urlfetchstrategy_bad_url(tmpdir):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('secure', [True, False])
|
@pytest.mark.parametrize('secure', [True, False])
|
||||||
|
@pytest.mark.parametrize('mock_archive',
|
||||||
|
[('.tar.gz', 'z'), ('.tgz', 'z'),
|
||||||
|
('.tar.bz2', 'j'), ('.tbz2', 'j'),
|
||||||
|
('.tar.xz', 'J'), ('.txz', 'J')],
|
||||||
|
indirect=True)
|
||||||
def test_fetch(
|
def test_fetch(
|
||||||
mock_archive,
|
mock_archive,
|
||||||
secure,
|
secure,
|
||||||
|
@ -10,11 +10,12 @@
|
|||||||
|
|
||||||
# Supported archive extensions.
|
# Supported archive extensions.
|
||||||
PRE_EXTS = ["tar", "TAR"]
|
PRE_EXTS = ["tar", "TAR"]
|
||||||
EXTS = ["gz", "bz2", "xz", "Z", "zip", "tgz", "tbz2", "txz"]
|
EXTS = ["gz", "bz2", "xz", "Z"]
|
||||||
|
NOTAR_EXTS = ["zip", "tgz", "tbz2", "txz"]
|
||||||
|
|
||||||
# Add PRE_EXTS and EXTS last so that .tar.gz is matched *before* .tar or .gz
|
# Add PRE_EXTS and EXTS last so that .tar.gz is matched *before* .tar or .gz
|
||||||
ALLOWED_ARCHIVE_TYPES = [".".join(l) for l in product(
|
ALLOWED_ARCHIVE_TYPES = [".".join(l) for l in product(
|
||||||
PRE_EXTS, EXTS)] + PRE_EXTS + EXTS
|
PRE_EXTS, EXTS)] + PRE_EXTS + EXTS + NOTAR_EXTS
|
||||||
|
|
||||||
|
|
||||||
def allowed_archive(path):
|
def allowed_archive(path):
|
||||||
|
Loading…
Reference in New Issue
Block a user