diff --git a/avocado/plugins/datadir.py b/avocado/plugins/datadir.py deleted file mode 100644 index 6c04fbee083324aa958311d15f07dba307271e6d..0000000000000000000000000000000000000000 --- a/avocado/plugins/datadir.py +++ /dev/null @@ -1,56 +0,0 @@ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# -# See LICENSE for more details. -# -# Copyright: Red Hat Inc. 2013-2014 -# Author: Lucas Meneghel Rodrigues - -from avocado.plugins import plugin -from avocado.core import output -from avocado.core import data_dir -from avocado.settings import settings - - -class DataDirList(plugin.Plugin): - - """ - Implements the avocado 'datadir' subcommand - """ - - name = 'datadir' - enabled = True - - def configure(self, parser): - self.parser = parser.subcommands.add_parser( - 'datadir', - help='List all relevant directories used by avocado') - super(DataDirList, self).configure(self.parser) - - def run(self, args): - view = output.View() - view.notify(event="message", msg='Config files read (in order):') - for cfg_path in settings.config_paths: - view.notify(event="message", msg=' %s' % cfg_path) - if settings.config_paths_failed: - view.notify(event="minor", msg='') - view.notify(event="error", msg='Config files that failed to read:') - for cfg_path in settings.config_paths_failed: - view.notify(event="error", msg=' %s' % cfg_path) - view.notify(event="message", msg='') - view.notify(event="minor", msg="Avocado replaces config dirs that can't be accessed") - view.notify(event="minor", msg="with sensible defaults. Please edit your local config") - view.notify(event="minor", msg="file to customize values") - view.notify(event="message", msg='') - view.notify(event="message", msg='Avocado Data Directories:') - view.notify(event="minor", msg=' base dir ' + data_dir.get_base_dir()) - view.notify(event="minor", msg=' tests dir ' + data_dir.get_test_dir()) - view.notify(event="minor", msg=' data dir ' + data_dir.get_data_dir()) - view.notify(event="minor", msg=' logs dir ' + data_dir.get_logs_dir()) - view.notify(event="minor", msg=' tmp dir ' + data_dir.get_tmp_dir()) diff --git a/docs/source/Configuration.rst b/docs/source/Configuration.rst index 50583f6ac3a66a1527be193fa8b692917c0e2a86..72ca792b9b714ac75966c0d914df5801a31ed8d4 100644 --- a/docs/source/Configuration.rst +++ b/docs/source/Configuration.rst @@ -31,7 +31,9 @@ Config file parsing order Avocado starts by parsing what it calls system wide config file, that is shipped to all avocado users on a system wide directory, ``/etc/avocado/avocado.conf``. Then it'll verify if there's a local user config file, that is located usually in ``~/.config/avocado/avocado.conf``. The order of the parsing matters, so the system wide file is parsed, -then the user config file is parsed last, so that the user can override values at will. +then the user config file is parsed last, so that the user can override values at will. There is another directory +that will be scanned by extra config files, ``/etc/avocado/conf.d``. This directory may contain plugin config files, +and extra additional config files that the system administrator/avocado developers might judge necessary to put there. Please note that for base directories, if you chose a directory that can't be properly used by avocado (some directories require read access, others, read and write access), avocado will fall back to some defaults. So if your regular user @@ -43,8 +45,8 @@ Plugin config files Plugins can also be configured by config files. In order to not disturb the main avocado config file, those plugins, if they wish so, may install additional config files to ``/etc/avocado/conf.d/[pluginname].conf``, that will be parsed -after the system wide config file. Users can override those values as well at the local config file level. So considering -the hypothetical plugin config:: +after the system wide config file. Users can override those values as well at the local config file level. +Considering the hypothetical plugin config:: [plugin.salad] base = ceasar @@ -84,3 +86,50 @@ configuration, after all the files are parsed in their correct resolution order. The command also shows the order in which your config files were parsed, giving you a better understanding of what's going on. The Section.Key nomenclature was inspired in ``git config --list`` output. + +Avocado Data Directories +======================== + +When running tests, we are frequently looking to: + +* Locate tests +* Write logs to a given location +* Grab files that will be useful for tests, such as ISO files or VM disk + images + +Avocado has a module dedicated to find those paths, to avoid cumbersome +path manipulation magic that people had to do in previous test frameworks [1]. + +If you want to list all relevant directories for your test, you can use +`avocado config --datadir` command to list those directories. Executing +it will give you an output similar to the one seen below:: + + $ avocado config --datadir + Config files read (in order): + /etc/avocado/avocado.conf + /home/lmr/.config/avocado/avocado.conf + + Avocado replaces config dirs that can't be accessed + with sensible defaults. Please edit your local config + file to customize values + + Avocado Data Directories: + base /home/lmr/avocado + tests /home/lmr/Code/avocado.lmr/examples/tests + data /home/lmr/avocado/data + logs /home/lmr/avocado/job-results + tmp /var/tmp/avocado + +Note that, while avocado will do its best to use the config values you +provide in the config file, if it can't write values to the locations +provided, it will fall back to (we hope) reasonable defaults, and we +notify the user about that in the output of the command. + +The relevant API documentation and meaning of each of those data directories +is in :mod:`avocado.core.data_dir`, so it's higly recommended you take a look. + +You may set your preferred data dirs by setting them in the avocado config files. +The next section of the documentation explains how you can see and set config +values that modify the behavior for the avocado utilities and plugins. + +[1] For example, autotest. diff --git a/docs/source/DataDir.rst b/docs/source/DataDir.rst deleted file mode 100644 index c67bc4c375d53274237cbe3a481167816f4f144f..0000000000000000000000000000000000000000 --- a/docs/source/DataDir.rst +++ /dev/null @@ -1,33 +0,0 @@ -======================== -Avocado Data Directories -======================== - -When running tests, we are frequently looking to: - -* Locate tests -* Write logs to a given location -* Grab files that will be useful for tests, such as ISO files or VM disk - images - -Avocado has a module dedicated to find those paths, to avoid cumbersome -path manipulation magic that people had to do in previous test frameworks [1]. - -If you want to list all relevant directories for your test, there's a builtin -avocado plugin called ``datadir`` to do that. You can run:: - - $ avocado datadir - Avocado Data Directories: - base dir: /home/lmr/avocado - tests dir: /home/lmr/avocado/tests - data dir: /home/lmr/avocado/data - logs dir: /home/lmr/avocado/logs - tmp dir: /tmp/avocado - -The relevant API documentation and meaning of each of those data directories -is in :mod:`avocado.core.data_dir`, so it's higly recommended you take a look. - -You may set your preferred data dirs by setting them in the avocado config files. -The next section of the documentation explains how you can see and set config -values that modify the behavior for the avocado utilities and plugins. - -[1] For example, autotest. \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index aa0f7a42a0f351bc62d23c144064d40c5faeaa2d..1206a810ff7a10d0daf2785d8d8dce387f850d33 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -14,7 +14,6 @@ Contents: Introduction GetStartedGuide - DataDir Configuration WritingTests ResultsSpecification diff --git a/selftests/all/functional/avocado/basic_tests.py b/selftests/all/functional/avocado/basic_tests.py index 9c561532ac36873a29e11122f40664c9aa47b7b9..c72f612fba3ec09f68972fa4c40b92ae3d6b6ea3 100644 --- a/selftests/all/functional/avocado/basic_tests.py +++ b/selftests/all/functional/avocado/basic_tests.py @@ -348,9 +348,20 @@ class PluginsTest(unittest.TestCase): (expected_rc, result)) self.assertNotIn('Disabled', output) - def test_datadir_plugin(self): + def test_config_plugin(self): os.chdir(basedir) - cmd_line = './scripts/avocado datadir' + cmd_line = './scripts/avocado config' + result = process.run(cmd_line, ignore_status=True) + output = result.stdout + expected_rc = 0 + self.assertEqual(result.exit_status, expected_rc, + "Avocado did not return rc %d:\n%s" % + (expected_rc, result)) + self.assertNotIn('Disabled', output) + + def test_config_plugin_datadir(self): + os.chdir(basedir) + cmd_line = './scripts/avocado config --datadir' result = process.run(cmd_line, ignore_status=True) output = result.stdout expected_rc = 0