summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/cmd/test.py26
-rwxr-xr-xshare/spack/spack-completion.bash7
2 files changed, 27 insertions, 6 deletions
diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py
index 3eff089ac8..58d520e457 100644
--- a/lib/spack/spack/cmd/test.py
+++ b/lib/spack/spack/cmd/test.py
@@ -89,6 +89,12 @@ def setup_parser(subparser):
"-a", "--all", action="store_true", dest="list_all",
help="list all packages with tests (not just installed)")
+ list_parser.add_argument(
+ 'tag',
+ nargs='*',
+ help="limit packages to those with all listed tags"
+ )
+
# Find
find_parser = sp.add_parser('find', description=test_find.__doc__,
help=first_line(test_find.__doc__))
@@ -214,15 +220,25 @@ def has_test_method(pkg):
def test_list(args):
"""List installed packages with available tests."""
+ tagged = set(spack.repo.path.packages_with_tags(*args.tag)) if args.tag \
+ else set()
+
+ def has_test_and_tags(pkg_class):
+ return has_test_method(pkg_class) and \
+ (not args.tag or pkg_class.name in tagged)
+
if args.list_all:
- all_packages_with_tests = [
+ report_packages = [
pkg_class.name
for pkg_class in spack.repo.path.all_package_classes()
- if has_test_method(pkg_class)
+ if has_test_and_tags(pkg_class)
]
+
if sys.stdout.isatty():
- tty.msg("%d packages with tests." % len(all_packages_with_tests))
- colify.colify(all_packages_with_tests)
+ filtered = ' tagged' if args.tag else ''
+ tty.msg("{0}{1} packages with tests.".
+ format(len(report_packages), filtered))
+ colify.colify(report_packages)
return
# TODO: This can be extended to have all of the output formatting options
@@ -231,7 +247,7 @@ def test_list(args):
hashes = env.all_hashes() if env else None
specs = spack.store.db.query(hashes=hashes)
- specs = list(filter(lambda s: has_test_method(s.package_class), specs))
+ specs = list(filter(lambda s: has_test_and_tags(s.package_class), specs))
spack.cmd.display_specs(specs, long=True)
diff --git a/share/spack/spack-completion.bash b/share/spack/spack-completion.bash
index c34c954e5e..a5610f5872 100755
--- a/share/spack/spack-completion.bash
+++ b/share/spack/spack-completion.bash
@@ -1696,7 +1696,12 @@ _spack_test_run() {
}
_spack_test_list() {
- SPACK_COMPREPLY="-h --help -a --all"
+ if $list_options
+ then
+ SPACK_COMPREPLY="-h --help -a --all"
+ else
+ SPACK_COMPREPLY=""
+ fi
}
_spack_test_find() {