Add tag filters to spack test list
(#26842)
This commit is contained in:
parent
94e0bf0112
commit
9d3d7c68fb
2 changed files with 27 additions and 6 deletions
|
@ -89,6 +89,12 @@ def setup_parser(subparser):
|
||||||
"-a", "--all", action="store_true", dest="list_all",
|
"-a", "--all", action="store_true", dest="list_all",
|
||||||
help="list all packages with tests (not just installed)")
|
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
|
||||||
find_parser = sp.add_parser('find', description=test_find.__doc__,
|
find_parser = sp.add_parser('find', description=test_find.__doc__,
|
||||||
help=first_line(test_find.__doc__))
|
help=first_line(test_find.__doc__))
|
||||||
|
@ -214,15 +220,25 @@ def has_test_method(pkg):
|
||||||
|
|
||||||
def test_list(args):
|
def test_list(args):
|
||||||
"""List installed packages with available tests."""
|
"""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:
|
if args.list_all:
|
||||||
all_packages_with_tests = [
|
report_packages = [
|
||||||
pkg_class.name
|
pkg_class.name
|
||||||
for pkg_class in spack.repo.path.all_package_classes()
|
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():
|
if sys.stdout.isatty():
|
||||||
tty.msg("%d packages with tests." % len(all_packages_with_tests))
|
filtered = ' tagged' if args.tag else ''
|
||||||
colify.colify(all_packages_with_tests)
|
tty.msg("{0}{1} packages with tests.".
|
||||||
|
format(len(report_packages), filtered))
|
||||||
|
colify.colify(report_packages)
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO: This can be extended to have all of the output formatting options
|
# 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
|
hashes = env.all_hashes() if env else None
|
||||||
|
|
||||||
specs = spack.store.db.query(hashes=hashes)
|
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)
|
spack.cmd.display_specs(specs, long=True)
|
||||||
|
|
||||||
|
|
|
@ -1696,7 +1696,12 @@ _spack_test_run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_spack_test_list() {
|
_spack_test_list() {
|
||||||
|
if $list_options
|
||||||
|
then
|
||||||
SPACK_COMPREPLY="-h --help -a --all"
|
SPACK_COMPREPLY="-h --help -a --all"
|
||||||
|
else
|
||||||
|
SPACK_COMPREPLY=""
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_spack_test_find() {
|
_spack_test_find() {
|
||||||
|
|
Loading…
Reference in a new issue