From 4f124bc9e7897b682fd18d605b6b6a007c7bfa15 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Wed, 27 Oct 2021 04:10:39 -0700 Subject: tests: speed up `spack list` tests (#26958) `spack list` tests are not using mock packages for some reason, and many are marked as potentially slow. This isn't really necessary; we don't need 6,000 packages to test the command. - [x] update tests to use `mock_packages` fixture - [x] remove `maybeslow` annotations --- lib/spack/spack/cmd/list.py | 10 ++++-- lib/spack/spack/test/cmd/list.py | 67 ++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 36 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/list.py b/lib/spack/spack/cmd/list.py index 80f7e7a287..b85ecc6057 100644 --- a/lib/spack/spack/cmd/list.py +++ b/lib/spack/spack/cmd/list.py @@ -221,9 +221,13 @@ def html(pkg_names, out): out.write('
Homepage:
\n') out.write('
\n') out.write('
Spack package:
\n') diff --git a/lib/spack/spack/test/cmd/list.py b/lib/spack/spack/test/cmd/list.py index f99b7420a4..b0adeb7e55 100644 --- a/lib/spack/spack/test/cmd/list.py +++ b/lib/spack/spack/test/cmd/list.py @@ -3,8 +3,6 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) -import pytest - from spack.main import SpackCommand list = SpackCommand('list') @@ -16,62 +14,65 @@ def test_list(): assert 'hdf5' in output -def test_list_filter(): +def test_list_filter(mock_packages): output = list('py-*') - assert 'py-numpy' in output - assert 'perl-file-copy-recursive' not in output + assert 'py-extension1' in output + assert 'py-extension2' in output + assert 'py-extension3' in output + assert 'python' not in output + assert 'mpich' not in output - output = list('py-') - assert 'py-numpy' in output - assert 'perl-file-copy-recursive' in output + output = list('py') + assert 'py-extension1' in output + assert 'py-extension2' in output + assert 'py-extension3' in output + assert 'python' in output + assert 'mpich' not in output -@pytest.mark.maybeslow -def test_list_search_description(): - output = list('--search-description', 'xml') - assert 'expat' in output +def test_list_search_description(mock_packages): + output = list('--search-description', 'one build dependency') + assert 'depb' in output -def test_list_tags(): - output = list('--tag', 'proxy-app') - assert 'cloverleaf3d' in output - assert 'hdf5' not in output +def test_list_tags(mock_packages): + output = list('--tag', 'tag1') + assert 'mpich' in output + assert 'mpich2' in output - output = list('--tag', 'hpc') - assert 'nek5000' in output - assert 'mfem' in output + output = list('--tag', 'tag2') + assert 'mpich\n' in output + assert 'mpich2' not in output - output = list('--tag', 'HPC') - assert 'nek5000' in output - assert 'mfem' in output + output = list('--tag', 'tag3') + assert 'mpich\n' not in output + assert 'mpich2' in output -def test_list_format_name_only(): +def test_list_format_name_only(mock_packages): output = list('--format', 'name_only') - assert 'cloverleaf3d' in output + assert 'zmpi' in output assert 'hdf5' in output -@pytest.mark.maybeslow -def test_list_format_version_json(): +def test_list_format_version_json(mock_packages): output = list('--format', 'version_json') - assert ' {"name": "cloverleaf3d",' in output - assert ' {"name": "hdf5",' in output + assert '{"name": "zmpi",' in output + assert '{"name": "dyninst",' in output import json json.loads(output) -@pytest.mark.maybeslow -def test_list_format_html(): +def test_list_format_html(mock_packages): output = list('--format', 'html') - assert '
' in output - assert '

cloverleaf3d' in output + assert '
' in output + assert '

zmpi' in output assert '
' in output assert '

hdf5' in output -def test_list_update(tmpdir): +def test_list_update(tmpdir, mock_packages): update_file = tmpdir.join('output') # not yet created when list is run -- cgit v1.2.3-60-g2f50