diff --git a/buildtest/cli/build.py b/buildtest/cli/build.py index aa4f4a931..85a5f0aba 100644 --- a/buildtest/cli/build.py +++ b/buildtest/cli/build.py @@ -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() diff --git a/buildtest/cli/help.py b/buildtest/cli/help.py index 65827120a..225972974 100644 --- a/buildtest/cli/help.py +++ b/buildtest/cli/help.py @@ -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 -e ", "Building buildspecs by executor", diff --git a/docs/gettingstarted/buildingtest.rst b/docs/gettingstarted/buildingtest.rst index d05e3b1c6..e6de28af8 100644 --- a/docs/gettingstarted/buildingtest.rst +++ b/docs/gettingstarted/buildingtest.rst @@ -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. diff --git a/scripts/spack_container/doc-examples.py b/scripts/spack_container/doc-examples.py index d9b8326c9..2ef22832d 100644 --- a/scripts/spack_container/doc-examples.py +++ b/scripts/spack_container/doc-examples.py @@ -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" diff --git a/tests/cli/test_build.py b/tests/cli/test_build.py index f7778cfc7..c7debbd80 100644 --- a/tests/cli/test_build.py +++ b/tests/cli/test_build.py @@ -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():