diff --git a/bash_completion.sh b/bash_completion.sh index 86281617c..ca5eab07d 100644 --- a/bash_completion.sh +++ b/bash_completion.sh @@ -413,8 +413,8 @@ _buildtest () COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) );; # completion for rest of arguments *) - local longopts="--buildspec --count --executors --filter --filterfields --format --formatfields --group-by-executor --group-by-tags --help --helpfilter --helpformat --no-header --pager --paths --quiet --rebuild --row-count --tags --root --terse" - local shortopts="-b -e -h -n -p -q -r -t" + local longopts="--buildspec --count --directory --executors --filter --filterfields --format --formatfields --group-by-executor --group-by-tags --help --helpfilter --helpformat --no-header --pager --paths --quiet --rebuild --row-count --tags --terse" + local shortopts="-b -d -e -h -n -p -q -r -t" local cmds="invalid" COMPREPLY=( $( compgen -W "${cmds} ${longopts} ${shortopts}" -- "${cur}" ) ) diff --git a/buildtest/cli/__init__.py b/buildtest/cli/__init__.py index 2b34dedfa..71fb629f5 100644 --- a/buildtest/cli/__init__.py +++ b/buildtest/cli/__init__.py @@ -1287,7 +1287,7 @@ def buildspec_find_menu(self, buildspec_find_parser): }, ), ( - ["--root"], + ["-d", "--directory"], { "type": str, "action": "append", diff --git a/buildtest/cli/buildspec.py b/buildtest/cli/buildspec.py index 35ee16896..14996002b 100644 --- a/buildtest/cli/buildspec.py +++ b/buildtest/cli/buildspec.py @@ -49,7 +49,7 @@ def __init__( rebuild=False, filterfields=None, formatfields=None, - roots=None, + directory=None, header=None, terse=None, pager=None, @@ -58,7 +58,7 @@ def __init__( row_count=None, ): """The initializer method for BuildspecCache class is responsible for loading and finding buildspecs into buildspec cache. First we - resolve paths to directory where buildspecs will be searched. This can be specified via ``--roots`` option on command line or one can + resolve paths to directory where buildspecs will be searched. This can be specified via ``--directory`` option on command line or one can specify directory paths in the configuration file. Next we build the cache that contains metadata for each buildspec that will be written to file. If any filter or format options are specified we check if they are valid and finally display a content of the cache depending on the argument. @@ -70,7 +70,7 @@ def __init__( rebuild (bool, optional): rebuild the buildspec cache by validating all buildspecs when using ``buildtest buildspec find --rebuild``. Defaults to ``False`` if ``--rebuild`` is not specified filterfields (str, optional): The filter options specified via ``buildtest buildspec find --filter`` that contains list of key value pairs for filtering buildspecs formatfields (str, optional): The format options used for formating table. The format option is a comma separated list of format fields specified via ``buildtest buildspec find --format`` - roots (list, optional): List of directories to search for buildspecs. This argument contains value of ``buildtest buildspec find --roots`` + directory (list, optional): List of directories to search for buildspecs. This argument contains value of ``buildtest buildspec find --directory`` headers (bool, optional): Option to control whether header are printed in terse output. This argument contains value of ``buildtest buildspec find --no-header`` terse (bool, optional): Enable terse mode when printing output. In this mode we don't print output in table format instead output is printed in parseable format. This option can be specified via ``buildtest buildspec find --terse`` color (str, optional): An instance of a string class that selects the color to use when printing table output @@ -98,8 +98,10 @@ def __init__( self.row_count = row_count # if --root is not specified we set to empty list instead of None - self.roots = ( - roots or self.configuration.target_config["buildspecs"].get("root") or [] + self.directory = ( + directory + or self.configuration.target_config["buildspecs"].get("directory") + or [] ) # list of buildspec directories to search for .yml files @@ -117,7 +119,7 @@ def __init__( "rebuild" ) # if --root is specified we set rebuild to True - if self.roots: + if self.directory: self.rebuild = True self.cache = {} @@ -138,20 +140,20 @@ def load_paths(self): """Add all paths to search for buildspecs. We read configuration file and check whether we need to load buildspecs from list of directories. We check if directories exist, if any fail we don't add them to path. - If no root directories are specified we load the default buildspec roots which are + If no root directories are specified we load buildspecs in `tutorials `_ and `general_tests `_ directory. """ - # if no roots specified we load the default buildspec roots. - if not self.roots: + # if no directory is specified we load the default buildspec. + if not self.directory: self.paths += BUILDSPEC_DEFAULT_PATH # for every root buildspec defined in configuration or via --root option, # we resolve path and if path exist add to self.paths. The path must be a # directory. If its file, we ignore it - if self.roots: - for root in self.roots: + if self.directory: + for root in self.directory: path = resolve_path(root, exist=False) if not os.path.exists(path): console.print(f"[red]Path: {path} does not exist!") @@ -297,8 +299,8 @@ def lookup_buildspec_by_name(self, name): def build_cache(self): """This method will rebuild the buildspec cache file by recursively searching - all .yml files specified by input argument ``paths`` which is a list of directory - roots. The buildspecs are validated and cache file is updated + all .yml files specified by input argument ``paths`` which is a list of directory paths. + The buildspecs are validated and cache file is updated """ self.update_cache = {} @@ -1402,7 +1404,7 @@ def buildspec_find(args, configuration): rebuild=args.rebuild, filterfields=args.filter, formatfields=args.format, - roots=args.root, + directory=args.directory, configuration=configuration, header=args.no_header, terse=args.terse, diff --git a/buildtest/cli/show.py b/buildtest/cli/show.py index 28522e812..93562c82d 100644 --- a/buildtest/cli/show.py +++ b/buildtest/cli/show.py @@ -134,7 +134,7 @@ def print_buildspec_show(): "buildtest buildspec find --pager", "Paginate output of buildspec cache" ) table.add_row( - "buildtest buildspec find --root /tmp --rebuild", + "buildtest buildspec find --directory /tmp --rebuild", "Discover buildspecs in /tmp and rebuild buildspec cache", ) table.add_row( diff --git a/buildtest/main.py b/buildtest/main.py index 6f8f1ab03..52a8983f7 100644 --- a/buildtest/main.py +++ b/buildtest/main.py @@ -252,10 +252,10 @@ def setup(args): # build buildspec cache file automatically if it doesn't exist if not is_file(BUILDSPEC_CACHE_FILE): root_buildspecs = [] - if hasattr(args, "root"): - root_buildspecs = args.root + if hasattr(args, "directory"): + root_buildspecs = args.directory - BuildspecCache(roots=root_buildspecs, configuration=configuration) + BuildspecCache(directory=root_buildspecs, configuration=configuration) return system, configuration, buildtest_editor, report_file diff --git a/buildtest/schemas/settings.schema.json b/buildtest/schemas/settings.schema.json index 67abce896..1656e2074 100644 --- a/buildtest/schemas/settings.schema.json +++ b/buildtest/schemas/settings.schema.json @@ -108,7 +108,7 @@ "$ref": "#/definitions/format" }, "terse": { "$ref": "#/definitions/terse" }, - "root": { + "directory": { "type": "array", "items": { "type": "string" diff --git a/buildtest/settings/aws.yml b/buildtest/settings/aws.yml index f5bdae666..c25029ffa 100644 --- a/buildtest/settings/aws.yml +++ b/buildtest/settings/aws.yml @@ -10,7 +10,7 @@ system: count: 15 format: name,description terse: false - root: + directory: - $BUILDTEST_ROOT/aws_tutorial report: count: 25 diff --git a/buildtest/settings/aws_oddc_pbs.yml b/buildtest/settings/aws_oddc_pbs.yml index 520279bbe..50dfe30b2 100644 --- a/buildtest/settings/aws_oddc_pbs.yml +++ b/buildtest/settings/aws_oddc_pbs.yml @@ -10,7 +10,7 @@ system: count: 15 format: name,description terse: false - root: + directory: - $BUILDTEST_ROOT/aws_oddc report: count: 25 diff --git a/buildtest/settings/config.yml b/buildtest/settings/config.yml index 0eba2d01f..eef02db9c 100644 --- a/buildtest/settings/config.yml +++ b/buildtest/settings/config.yml @@ -34,7 +34,7 @@ system: terse: false # list of paths to search for buildspecs - #root: ["$BUILDTEST_ROOT/tutorials", "$BUILDTEST_ROOT/examples"] + #directory: ["$BUILDTEST_ROOT/tutorials", "$BUILDTEST_ROOT/examples"] # options for buildtest report command report: diff --git a/buildtest/settings/spack_container.yml b/buildtest/settings/spack_container.yml index 040f3da77..3f1f23dd6 100644 --- a/buildtest/settings/spack_container.yml +++ b/buildtest/settings/spack_container.yml @@ -11,7 +11,7 @@ system: count: 15 format: name,description terse: false - root: + directory: - $BUILDTEST_ROOT/examples report: count: 25 diff --git a/docs/buildtest_perlmutter.rst b/docs/buildtest_perlmutter.rst index d4e170d64..c19d6e4c4 100644 --- a/docs/buildtest_perlmutter.rst +++ b/docs/buildtest_perlmutter.rst @@ -76,7 +76,7 @@ Exercise 2: Querying Buildspec Cache In this exercise you will learn how to use the :ref:`buildspec_interface`. Let's build the cache by running the following:: - buildtest buildspec find --root $HOME/buildtest-nersc/buildspecs --rebuild -q + buildtest buildspec find --directory $HOME/buildtest-nersc/buildspecs --rebuild -q .. todo:: diff --git a/docs/configuring_buildtest/overview.rst b/docs/configuring_buildtest/overview.rst index 2611667e5..f566bd402 100644 --- a/docs/configuring_buildtest/overview.rst +++ b/docs/configuring_buildtest/overview.rst @@ -225,21 +225,21 @@ can be overridden by command line option. Specify Root Directories for searching buildspecs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Buildtest will search for buildspecs by recursively searching for files with **.yml** extension. The ``root`` property in configuration file -is a list of string types which is used to search for buildspecs. The ``root`` property is not required in configuration file, but it can be a good -idea to set this value if you have a predetermined location where buildspecs are stored. +Buildtest will search for buildspecs by recursively searching for files with **.yml** extension. The ``directory`` property in configuration file +is a list of directories to search for buildspecs. The ``directory`` property is not **required** in configuration file, but it can be a good +idea to set this value if you have a pre-determined location where buildspecs are stored. -You can specify the root path via command line ``buildtest buildspec find --root --root `` which will override the configuration value. In a +You can specify the directory path via command line ``buildtest buildspec find --directory --directory `` which will override the configuration value. In a practical situation, you will want to write your buildspecs in a separate repository which you can clone in your filesystem. Let's say they are cloned in -your $HOME directory named **$HOME/buildtest-examples**. You have one of two options, one you can specify the root path in configuration file as shown below: +your **$HOME** directory named **$HOME/buildtest-examples**. You have one of two options, one you can specify the path in configuration file as shown below: .. code-block:: yaml buildspecs: - root: [ $HOME/buildtest-examples ] + directory: [ $HOME/buildtest-examples ] -This above configuration will instruct buildtest to search for buildspecs in ``$HOME/buildtest-examples`` directory, and you won't -have to specify the ``--root`` option when running ``buildtest buildspec find``. The second option would be to specify the ``--root`` everytime +This configuration will instruct buildtest to search for buildspecs in ``$HOME/buildtest-examples`` directory, and you won't +have to specify the ``--directory`` option when running ``buildtest buildspec find``. The second option would be to specify the ``--directory`` everytime you need to build the cache. If neither is specified, buildtest will load the default buildspecs which are **$BUILDTEST_ROOT/tutorials** and **$BUILDTEST_ROOT/general_tests**. diff --git a/docs/gettingstarted/buildspecs_interface.rst b/docs/gettingstarted/buildspecs_interface.rst index 20148198b..1be2281e8 100644 --- a/docs/gettingstarted/buildspecs_interface.rst +++ b/docs/gettingstarted/buildspecs_interface.rst @@ -92,21 +92,21 @@ or pass them via command line. buildtest will search buildspecs in :ref:`buildspecs root ` defined in your configuration, which is a list of directory paths to search for buildspecs. If you want to load buildspecs from a directory path, you can specify a directory -via ``--root`` option in the format: ``buildtest buildspec find --root ``. -buildtest will rebuild cache when `--root` option is specified. Note that to rebuild cache you typically -need to pass **--rebuild** option but that is not required when using **--root** option because we want +via ``--directory`` option in the format: ``buildtest buildspec find --directory ``. +buildtest will rebuild cache when `--directory` option is specified. Note that to rebuild cache you typically +need to pass **--rebuild** option but that is not required when using **--directory** option because we want buildtest to load buildspecs into cache. -The **--root** option must be path to a directory, if you specify a file path then buildtest will report an error message similar +The **--directory** option must be path to a directory, if you specify a file path then buildtest will report an error message similar to one below -.. dropdown:: ``buildtest buildspec find --root $BUILDTEST_ROOT/README.rst`` +.. dropdown:: ``buildtest buildspec find --directory $BUILDTEST_ROOT/README.rst`` :color: warning - .. command-output:: buildtest buildspec find --root $BUILDTEST_ROOT/README.rst + .. command-output:: buildtest buildspec find --directory $BUILDTEST_ROOT/README.rst :returncode: 1 -If you want to specify multiple root paths you can specify the **--root** options multiple times. +If you want to specify multiple root paths you can specify the **--directory** options multiple times. Let's rebuild the cache again by running ``buildtest buildspec find`` which will load the default buildspecs into the cache diff --git a/tests/buildsystem/spack_container.yml b/tests/buildsystem/spack_container.yml deleted file mode 100644 index ba9ba40c1..000000000 --- a/tests/buildsystem/spack_container.yml +++ /dev/null @@ -1,41 +0,0 @@ -system: - generic: - hostnames: - - .* - description: Generic System - moduletool: none - testdir: ~/runs - pager: false - buildspecs: - rebuild: false - count: 15 - format: name,description - terse: false - root: - - $BUILDTEST_ROOT/examples - report: - count: 25 - terse: false - format: name,id,state,runtime,returncode - executors: - local: - bash: - description: submit jobs on local machine using bash shell - shell: bash - sh: - description: submit jobs on local machine using sh shell - shell: sh - compilers: - find: - gcc: ^(gcc) - compiler: - gcc: - builtin_gcc: - cc: /usr/bin/gcc - fc: /usr/bin/gfortran - cxx: /usr/bin/g++ - cdash: - url: https://my.cdash.org/ - project: buildtest - site: generic - buildname: buildtest_spack_tutorial diff --git a/tests/buildsystem/test_spack.py b/tests/buildsystem/test_spack.py index 26d30f8c0..3f609bc9d 100644 --- a/tests/buildsystem/test_spack.py +++ b/tests/buildsystem/test_spack.py @@ -7,8 +7,7 @@ from buildtest.cli.build import BuildTest from buildtest.cli.buildspec import BuildspecCache from buildtest.config import SiteConfiguration - -here = os.path.dirname(os.path.abspath(__file__)) +from buildtest.defaults import BUILDTEST_ROOT @pytest.mark.spack @@ -21,7 +20,9 @@ def test_spack_examples(): ) configuration = SiteConfiguration( - settings_file=os.path.join(here, "spack_container.yml") + settings_file=os.path.join( + BUILDTEST_ROOT, "buildtest", "settings", "spack_container.yml" + ) ) configuration.detect_system() configuration.validate() diff --git a/tests/cli/test_buildspec.py b/tests/cli/test_buildspec.py index 5c1203489..9df01eda7 100644 --- a/tests/cli/test_buildspec.py +++ b/tests/cli/test_buildspec.py @@ -354,12 +354,14 @@ def test_buildspec_find_roots(): os.path.join(BUILDTEST_ROOT, "tutorials"), ] # buildtest buildspec find --root $BUILDTEST_ROOT/tests/buildsystem --root $BUILDTEST_ROOT/tutorials - BuildspecCache(roots=root_buildspecs, configuration=configuration, rebuild=False) + BuildspecCache( + directory=root_buildspecs, configuration=configuration, rebuild=False + ) with pytest.raises(BuildTestError): # buildtest buildspec find --root $BUILDTEST_ROOT/README.rst --root $BUILDTEST_ROOT/environment.yml BuildspecCache( - roots=[ + directory=[ os.path.join(BUILDTEST_ROOT, "README.rst"), os.path.join(BUILDTEST_ROOT, "tutorials", "environment.yml"), ], diff --git a/tests/settings/torque.yml b/tests/settings/torque.yml index 1db18cbe2..342868608 100644 --- a/tests/settings/torque.yml +++ b/tests/settings/torque.yml @@ -10,7 +10,7 @@ system: count: 15 format: name,description terse: false - root: + directory: - $BUILDTEST_ROOT/aws_oddc report: count: 25