diff options
author | Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> | 2021-11-02 02:00:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-02 10:00:21 +0100 |
commit | 9d3d7c68fb76d112ab048b2cc581d48bc22aa9f4 (patch) | |
tree | d5fdd24917b5ef168441a68c8c35e23790e625c1 /lib | |
parent | 94e0bf01126354b4d2491686b44032a0d42db57e (diff) | |
download | spack-9d3d7c68fb76d112ab048b2cc581d48bc22aa9f4.tar.gz spack-9d3d7c68fb76d112ab048b2cc581d48bc22aa9f4.tar.bz2 spack-9d3d7c68fb76d112ab048b2cc581d48bc22aa9f4.tar.xz spack-9d3d7c68fb76d112ab048b2cc581d48bc22aa9f4.zip |
Add tag filters to `spack test list` (#26842)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/test.py | 26 |
1 files changed, 21 insertions, 5 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) |