Add tag filters to spack test list
(#26842)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user