From 0c1f4a799700b92ef9bfd54d209ffb4c252f9fae Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Fri, 22 Dec 2017 13:29:20 -0500 Subject: Add more unit tests for spack list command (#6750) --- lib/spack/spack/test/cmd/list.py | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/test/cmd/list.py b/lib/spack/spack/test/cmd/list.py index 9fe335a6e3..976bacb9fb 100644 --- a/lib/spack/spack/test/cmd/list.py +++ b/lib/spack/spack/test/cmd/list.py @@ -55,7 +55,7 @@ def mock_name_only(monkeypatch, pkg_names): @pytest.mark.usefixtures('mock_name_only') class TestListCommand(object): - def test_list_without_filters(self, parser, pkg_names): + def test_list(self, parser, pkg_names): args = parser.parse_args([]) spack.cmd.list.list(parser, args) @@ -64,10 +64,40 @@ class TestListCommand(object): assert 'cloverleaf3d' in pkg_names assert 'hdf5' in pkg_names - def test_list_with_filters(self, parser, pkg_names): + def test_list_filter(self, parser, pkg_names): + args = parser.parse_args(['py-*']) + spack.cmd.list.list(parser, args) + + assert pkg_names + assert 'py-numpy' in pkg_names + assert 'perl-file-copy-recursive' not in pkg_names + + args = parser.parse_args(['py-']) + spack.cmd.list.list(parser, args) + + assert pkg_names + assert 'py-numpy' in pkg_names + assert 'perl-file-copy-recursive' in pkg_names + + def test_list_search_description(self, parser, pkg_names): + args = parser.parse_args(['--search-description', 'xml']) + spack.cmd.list.list(parser, args) + + assert pkg_names + assert 'expat' in pkg_names + + def test_list_tags(self, parser, pkg_names): args = parser.parse_args(['--tags', 'proxy-app']) spack.cmd.list.list(parser, args) assert pkg_names assert 'cloverleaf3d' in pkg_names assert 'hdf5' not in pkg_names + + def test_list_formatter(self, parser, pkg_names): + # TODO: Test the output of the commands + args = parser.parse_args(['--format', 'name_only']) + spack.cmd.list.list(parser, args) + + args = parser.parse_args(['--format', 'rst']) + spack.cmd.list.list(parser, args) -- cgit v1.2.3-70-g09d2