Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build by multiple tags by providing tagnames as comma seperated list #1419

Merged
merged 9 commits into from
Mar 10, 2023
6 changes: 6 additions & 0 deletions buildtest/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ def discover_buildspecs_by_tags(buildspec_cache, tagnames):
buildspecs = []
# query all buildspecs from BUILDSPEC_CACHE_FILE for tags keyword and
# if it matches input_tag we add buildspec to list
tagnames = [
tag.strip() for tagname in tagnames for tag in tagname.split(",") if tag.strip()
]

if not tagnames:
return buildspecs, buildspecs_by_tags

for name in tagnames:
buildspecs_by_tags[name] = set()
Expand Down
4 changes: 4 additions & 0 deletions buildtest/cli/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def print_build_help():
"buildtest build -t pass -t python",
"Build buildspecs by tagname 'pass' and 'python'",
)
table.add_row(
"buildtest build -t pass,fail",
"Build buildspecs by tagnames that are specified as comma sperated list",
)
table.add_row(
"buildtest build -e <executor1> -e <executor2>",
"Building buildspecs by executor",
Expand Down
7 changes: 7 additions & 0 deletions docs/gettingstarted/buildingtest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ tags by running ``buildtest buildspec find --tags``.
.. Note:: The ``--tags`` is used for discovering buildspec file and not filtering tests
by tag.

You can specify multiple tag names as a comma separated list. In the
example below we build all tests with tag names ``pass``, ``fail`` and ``network``.

.. dropdown:: ``buildtest build -t pass,fail -t network``

.. command-output:: buildtest build -t pass,fail -t network

You can combine ``--tags`` with ``--buildspec`` to discover buildspecs in a single command.
buildtest will query tags and buildspecs independently and combine all discovered
buildspecs together.
Expand Down
1 change: 0 additions & 1 deletion scripts/spack_container/doc-examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from buildtest.utils.file import create_dir, is_dir, is_file

if __name__ == "__main__":

if getpass.getuser() != "spack" or os.getenv("HOME") != "/home/spack":
sys.exit(
"This script can only be run inside container: ghcr.io/buildtesters/buildtest_spack:latest"
Expand Down
23 changes: 23 additions & 0 deletions tests/cli/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,29 @@ def test_build_by_tags():
)
cmd.build()

# testing multiple tags as comma seperated list: buildtest build --tags fail,python --tags network
cmd = BuildTest(
configuration=configuration,
tags=["fail,python", "network"],
buildtest_system=system,
)
cmd.build()

cmd = BuildTest(
configuration=configuration,
tags=[",,"],
buildtest_system=system,
)
with pytest.raises(SystemExit):
cmd.build()

cmd = BuildTest(
configuration=configuration,
tags=[" ,python, fail, ,,"],
buildtest_system=system,
)
cmd.build()


@pytest.mark.cli
def test_build_rerun():
Expand Down