Exemplo n.º 1
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: Main test runner parser.
        """
        parser = super(List, self).configure(parser)
        parser.add_argument('keywords',
                            type=str,
                            default=[],
                            nargs='*',
                            help="List of paths, aliases or other "
                            "keywords used to locate tests. "
                            "If empty, avocado will list tests on "
                            "the configured test source, "
                            "(see 'avocado config --datadir') Also, "
                            "if there are other test loader plugins "
                            "active, tests from those plugins might "
                            "also show up (behavior may vary among "
                            "plugins)")
        parser.add_argument('-V',
                            '--verbose',
                            action='store_true',
                            default=False,
                            help='Whether to show extra information '
                            '(headers and summary). Current: %(default)s')
        parser.add_argument('--paginator',
                            choices=('on', 'off'),
                            default='on',
                            help='Turn the paginator on/off. '
                            'Current: %(default)s')
        loader.add_loader_options(parser)
Exemplo n.º 2
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: Main test runner parser.
        """
        parser = super(List, self).configure(parser)
        parser.add_argument('keywords', type=str, default=[], nargs='*',
                            help="List of paths, aliases or other "
                            "keywords used to locate tests. "
                            "If empty, avocado will list tests on "
                            "the configured test source, "
                            "(see 'avocado config --datadir') Also, "
                            "if there are other test loader plugins "
                            "active, tests from those plugins might "
                            "also show up (behavior may vary among "
                            "plugins)")
        parser.add_argument('-V', '--verbose',
                            action='store_true', default=False,
                            help='Whether to show extra information '
                            '(headers and summary). Current: %(default)s')
        parser.add_argument('--paginator',
                            choices=('on', 'off'), default='on',
                            help='Turn the paginator on/off. '
                            'Current: %(default)s')
        loader.add_loader_options(parser)
Exemplo n.º 3
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: The Avocado command line application parser
        :type parser: :class:`avocado.core.parser.ArgumentParser`
        """
        parser = super(List, self).configure(parser)
        parser.add_argument('references',
                            type=str,
                            default=[],
                            nargs='*',
                            help="List of test references (aliases or paths). "
                            "If empty, avocado will list tests on "
                            "the configured test source, "
                            "(see 'avocado config --datadir') Also, "
                            "if there are other test loader plugins "
                            "active, tests from those plugins might "
                            "also show up (behavior may vary among "
                            "plugins)")
        parser.add_argument('-V',
                            '--verbose',
                            action='store_true',
                            default=False,
                            help='Whether to show extra information '
                            '(headers and summary). Current: %(default)s')
        parser.add_argument('--paginator',
                            choices=('on', 'off'),
                            default='on',
                            help='Turn the paginator on/off. '
                            'Current: %(default)s')
        loader.add_loader_options(parser)
        parser_common_args.add_tag_filter_args(parser)
Exemplo n.º 4
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: The Avocado command line application parser
        :type parser: :class:`avocado.core.parser.ArgumentParser`
        """
        parser = super(List, self).configure(parser)
        help_msg = ('List of test references (aliases or paths). If empty, '
                    'Avocado will list tests on the configured test source, '
                    '(see "avocado config --datadir") Also, if there are '
                    'other test loader plugins active, tests from those '
                    'plugins might also show up (behavior may vary among '
                    'plugins)')
        settings.register_option(section='list',
                                 key='references',
                                 default=[],
                                 nargs='*',
                                 key_type=list,
                                 help_msg=help_msg,
                                 parser=parser,
                                 positional_arg=True)
        loader.add_loader_options(parser, 'list')

        help_msg = ('What is the method used to detect tests? If --resolver '
                    'used, Avocado will use the Next Runner Resolver method. '
                    'If not the legacy one will be used.')
        settings.register_option(section='list',
                                 key='resolver',
                                 key_type=bool,
                                 default=False,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--resolver')

        help_msg = ('Writes runnable recipe files to a directory. Valid only '
                    'when using --resolver.')
        settings.register_option(section='list.recipes',
                                 key='write_to_directory',
                                 default=None,
                                 metavar='DIRECTORY',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--write-recipes-to-directory')

        help_msg = 'Writes output to a json file.'
        settings.register_option(section='list',
                                 key='write_to_json_file',
                                 default=None,
                                 metavar='JSON_FILE',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--json')

        parser_common_args.add_tag_filter_args(parser)
Exemplo n.º 5
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: Main test runner parser.
        """
        parser = super(List, self).configure(parser)
        parser.add_argument('reference',
                            type=str,
                            default=[],
                            nargs='*',
                            help="List of test references (aliases or paths). "
                            "If empty, avocado will list tests on "
                            "the configured test source, "
                            "(see 'avocado config --datadir') Also, "
                            "if there are other test loader plugins "
                            "active, tests from those plugins might "
                            "also show up (behavior may vary among "
                            "plugins)")
        parser.add_argument('-V',
                            '--verbose',
                            action='store_true',
                            default=False,
                            help='Whether to show extra information '
                            '(headers and summary). Current: %(default)s')
        parser.add_argument('--paginator',
                            choices=('on', 'off'),
                            default='on',
                            help='Turn the paginator on/off. '
                            'Current: %(default)s')
        loader.add_loader_options(parser)

        filtering = parser.add_argument_group('filtering parameters')
        filtering.add_argument('-t',
                               '--filter-by-tags',
                               metavar='TAGS',
                               action='append',
                               help='Filter INSTRUMENTED tests based on '
                               '":avocado: tags=tag1,tag2" notation in '
                               'their class docstring')
        filtering.add_argument('--filter-by-tags-include-empty',
                               action='store_true',
                               default=False,
                               help=('Include all tests without tags during '
                                     'filtering. This effectively means they '
                                     'will be kept in the test suite found '
                                     'previously to filtering.'))
        filtering.add_argument('--filter-by-tags-include-empty-key',
                               action='store_true',
                               default=False,
                               help=('Include all tests that do not have a '
                                     'matching key in its key:val tags. This '
                                     'effectively means those tests will be '
                                     'kept in the test suite found previously '
                                     'to filtering.'))
Exemplo n.º 6
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: Main test runner parser.
        """
        parser = super(List, self).configure(parser)
        parser.add_argument('reference', type=str, default=[], nargs='*',
                            help="List of test references (aliases or paths). "
                            "If empty, avocado will list tests on "
                            "the configured test source, "
                            "(see 'avocado config --datadir') Also, "
                            "if there are other test loader plugins "
                            "active, tests from those plugins might "
                            "also show up (behavior may vary among "
                            "plugins)")
        parser.add_argument('-V', '--verbose',
                            action='store_true', default=False,
                            help='Whether to show extra information '
                            '(headers and summary). Current: %(default)s')
        parser.add_argument('--paginator',
                            choices=('on', 'off'), default='on',
                            help='Turn the paginator on/off. '
                            'Current: %(default)s')
        loader.add_loader_options(parser)

        filtering = parser.add_argument_group('filtering parameters')
        filtering.add_argument('-t', '--filter-by-tags', metavar='TAGS',
                               action='append',
                               help='Filter INSTRUMENTED tests based on '
                               '":avocado: tags=tag1,tag2" notation in '
                               'their class docstring')
        filtering.add_argument('--filter-by-tags-include-empty',
                               action='store_true', default=False,
                               help=('Include all tests without tags during '
                                     'filtering. This effectively means they '
                                     'will be kept in the test suite found '
                                     'previously to filtering.'))
        filtering.add_argument('--filter-by-tags-include-empty-key',
                               action='store_true', default=False,
                               help=('Include all tests that do not have a '
                                     'matching key in its key:val tags. This '
                                     'effectively means those tests will be '
                                     'kept in the test suite found previously '
                                     'to filtering.'))
Exemplo n.º 7
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: The Avocado command line application parser
        :type parser: :class:`avocado.core.parser.ArgumentParser`
        """
        parser = super(List, self).configure(parser)
        help_msg = ('List of test references (aliases or paths). If empty, '
                    'Avocado will list tests on the configured test source, '
                    '(see "avocado config --datadir") Also, if there are '
                    'other test loader plugins active, tests from those '
                    'plugins might also show up (behavior may vary among '
                    'plugins)')
        settings.register_option(section='list',
                                 key='references',
                                 default=[],
                                 nargs='*',
                                 key_type=list,
                                 help_msg=help_msg,
                                 parser=parser,
                                 positional_arg=True)
        loader.add_loader_options(parser, 'list')
        parser_common_args.add_tag_filter_args(parser)
Exemplo n.º 8
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        parser.add_argument("reference", type=str, default=[], nargs='*',
                            metavar="TEST_REFERENCE",
                            help='List of test references (aliases or paths)')

        parser.add_argument("-d", "--dry-run", action="store_true",
                            help="Instead of running the test only "
                            "list them and log their params.")

        parser.add_argument('--force-job-id', dest='unique_job_id',
                            type=str, default=None,
                            help='Forces the use of a particular job ID. Used '
                            'internally when interacting with an avocado '
                            'server. You should not use this option '
                            'unless you know exactly what you\'re doing')

        parser.add_argument('--job-results-dir', action='store',
                            dest='logdir', default=None, metavar='DIRECTORY',
                            help=('Forces to use of an alternate job '
                                  'results directory.'))

        parser.add_argument('--job-timeout', action='store',
                            default=None, metavar='SECONDS',
                            help='Set the maximum amount of time (in SECONDS) '
                            'that tests are allowed to execute. '
                            'Values <= zero means "no timeout". '
                            'You can also use suffixes, like: '
                            ' s (seconds), m (minutes), h (hours). ')

        parser.add_argument('--failfast', choices=('on', 'off'),
                            help='Enable or disable the job interruption on '
                            'first failed test.')

        parser.add_argument('--keep-tmp', choices=('on', 'off'),
                            default='off', help='Keep job temporary files '
                            '(useful for avocado debugging). Defaults to off.')

        parser.add_argument('--ignore-missing-references', choices=('on', 'off'),
                            help="Force the job execution, even if some of "
                            "the test references are not resolved to tests.")

        sysinfo_default = settings.get_value('sysinfo.collect',
                                             'enabled',
                                             key_type='bool',
                                             default=True)
        sysinfo_default = 'on' if sysinfo_default is True else 'off'
        parser.add_argument('--sysinfo', choices=('on', 'off'),
                            default=sysinfo_default, help="Enable or disable "
                            "system information (hardware details, profilers, "
                            "etc.). Current:  %(default)s")

        parser.add_argument("--execution-order",
                            choices=("tests-per-variant",
                                     "variants-per-test"),
                            help="Defines the order of iterating through test "
                            "suite and test variants")

        parser.output = parser.add_argument_group('output and result format')

        parser.output.add_argument('-s', '--silent', action="store_true",
                                   default=argparse.SUPPRESS,
                                   help='Silence stdout')

        parser.output.add_argument('--show-job-log', action='store_true',
                                   default=False, help="Display only the job "
                                   "log on stdout. Useful for test debugging "
                                   "purposes. No output will be displayed if "
                                   "you also specify --silent")

        parser.output.add_argument("--store-logging-stream", nargs="*",
                                   default=[], metavar="STREAM[:LEVEL]",
                                   help="Store given logging STREAMs in "
                                   "$JOB_RESULTS_DIR/$STREAM.$LEVEL.")

        out_check = parser.add_argument_group('output check arguments')

        out_check.add_argument('--output-check-record',
                               choices=('none', 'all', 'stdout', 'stderr'),
                               default='none',
                               help="Record output streams of your tests "
                               "to reference files (valid options: none (do "
                               "not record output streams), all (record both "
                               "stdout and stderr), stdout (record only "
                               "stderr), stderr (record only stderr). "
                               'Current: %(default)s')

        out_check.add_argument('--output-check', choices=('on', 'off'),
                               default='on',
                               help="Enable or disable test output (stdout/"
                               "stderr) check. If this option is off, no "
                               "output will be checked, even if there are "
                               "reference files present for the test. "
                               "Current: on (output check enabled)")

        loader.add_loader_options(parser)

        filtering = parser.add_argument_group('filtering parameters')
        filtering.add_argument('-t', '--filter-by-tags', metavar='TAGS',
                               action='append',
                               help='Filter INSTRUMENTED tests based on '
                               '":avocado: tags=tag1,tag2" notation in '
                               'their class docstring')
        filtering.add_argument('--filter-by-tags-include-empty',
                               action='store_true', default=False,
                               help=('Include all tests without tags during '
                                     'filtering. This effectively means they '
                                     'will be kept in the test suite found '
                                     'previously to filtering.'))
Exemplo n.º 9
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        settings.add_argparser_to_option(namespace='run.references',
                                         parser=parser,
                                         positional_arg=True,
                                         nargs='*',
                                         metavar='TEST_REFERENCE')

        help_msg = ('Parameter name and value to pass to all tests. This is '
                    'only applicable when not using a varianter plugin. '
                    'This option format must be given in the NAME=VALUE '
                    'format, and may be given any number of times, or per '
                    'parameter.')
        settings.register_option(section='run',
                                 key='test_parameters',
                                 action='append',
                                 default=[],
                                 key_type=self._test_parameter,
                                 metavar="NAME_VALUE",
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--test-parameter',
                                 short_arg='-p')

        help_msg = ('Selects the runner implementation from one of the '
                    'installed and active implementations.  You can run '
                    '"avocado plugins" and find the list of valid runners '
                    'under the "Plugins that run test suites on a job '
                    '(runners) section.  Defaults to "runner", which is '
                    'the conventional and traditional runner.')
        settings.register_option(section='run',
                                 key='test_runner',
                                 default='runner',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--test-runner',
                                 metavar='TEST_RUNNER')

        help_msg = ('Instead of running the test only list them and log '
                    'their params.')
        settings.register_option(section='run.dry_run',
                                 key='enabled',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 short_arg='-d',
                                 long_arg='--dry-run')

        help_msg = ('Do not automatically clean up temporary directories '
                    'used by dry-run')
        settings.register_option(section='run.dry_run',
                                 key='no_cleanup',
                                 help_msg=help_msg,
                                 default=False,
                                 key_type=bool,
                                 parser=parser,
                                 long_arg='--dry-run-no-cleanup')

        help_msg = ('Forces the use of a particular job ID. Used internally '
                    'when interacting with an avocado server. You should not '
                    'use this option unless you know exactly what you\'re '
                    'doing')
        settings.register_option(section='run',
                                 key='unique_job_id',
                                 default=None,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--force-job-id',
                                 metavar='UNIQUE_JOB_ID')

        help_msg = 'Forces to use of an alternate job results directory.'
        settings.register_option(section='run',
                                 key='results_dir',
                                 default=None,
                                 metavar='DIRECTORY',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--job-results-dir')

        help_msg = ('Categorizes this within a directory with the same name, '
                    'by creating a link to the job result directory')
        settings.register_option(section='run',
                                 key='job_category',
                                 help_msg=help_msg,
                                 parser=parser,
                                 default=None,
                                 metavar='CATEGORY',
                                 long_arg='--job-category')

        settings.add_argparser_to_option(namespace='job.run.timeout',
                                         metavar='SECONDS',
                                         parser=parser,
                                         long_arg='--job-timeout')

        help_msg = 'Enable the job interruption on first failed test.'
        settings.register_option(section='run',
                                 key='failfast',
                                 default=False,
                                 key_type=bool,
                                 action='store_true',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--failfast')

        help_msg = 'Keep job temporary files (useful for avocado debugging).'
        settings.register_option(section='run',
                                 key='keep_tmp',
                                 default=False,
                                 key_type=bool,
                                 action='store_true',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--keep-tmp')

        help_msg = ('Force the job execution, even if some of the test '
                    'references are not resolved to tests. "on" and '
                    '"off" will be deprecated soon.')
        settings.register_option(section='run',
                                 key='ignore_missing_references',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--ignore-missing-references')

        settings.add_argparser_to_option(namespace='sysinfo.collect.enabled',
                                         parser=parser,
                                         action='store_false',
                                         long_arg='--disable-sysinfo')

        settings.add_argparser_to_option('run.execution_order',
                                         parser=parser,
                                         long_arg='--execution-order')

        parser.output = parser.add_argument_group('output and result format')

        settings.add_argparser_to_option('job.run.store_logging_stream',
                                         parser=parser.output,
                                         long_arg='--store-logging-stream',
                                         metavar='LOGGING_STREAM')

        help_msg = ('Logs the possible data directories for each test. This '
                    'is helpful when writing new tests and not being sure '
                    'where to put data files. Look for "Test data '
                    'directories" in your test log')
        settings.register_option(section='run',
                                 key='log_test_data_directories',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--log-test-data-directories')

        out_check = parser.add_argument_group('output check arguments')

        help_msg = ('Record the output produced by each test (from stdout '
                    'and stderr) into both the current executing result '
                    'and into reference files. Reference files are used on '
                    'subsequent runs to determine if the test produced the '
                    'expected output or not, and the current executing result '
                    'is used to check against a previously recorded reference '
                    'file.  Valid values: "none" (to explicitly disable all '
                    'recording) "stdout" (to record standard output *only*), '
                    '"stderr" (to record standard error *only*), "both" (to '
                    'record standard output and error in separate files), '
                    '"combined" (for standard output and error in a single '
                    'file). "all" is also a valid but deprecated option that '
                    'is a synonym of "both".')
        settings.register_option(section='run',
                                 key='output_check_record',
                                 help_msg=help_msg,
                                 choices=('none', 'stdout', 'stderr', 'both',
                                          'combined', 'all'),
                                 parser=out_check,
                                 default=None,
                                 long_arg='--output-check-record')

        help_msg = ('Disables test output (stdout/stderr) check. If this '
                    'option is given, no output will be checked, even if '
                    'there are reference files present for the test.')
        settings.register_option(section='run',
                                 key='output_check',
                                 default=True,
                                 key_type=bool,
                                 action='store_false',
                                 help_msg=help_msg,
                                 parser=out_check,
                                 long_arg='--disable-output-check')

        loader.add_loader_options(parser, 'run')
        parser_common_args.add_tag_filter_args(parser)
Exemplo n.º 10
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        parser.add_argument("reference",
                            type=str,
                            default=[],
                            nargs='*',
                            metavar="TEST_REFERENCE",
                            help='List of test references (aliases or paths)')

        parser.add_argument("-d",
                            "--dry-run",
                            action="store_true",
                            help="Instead of running the test only "
                            "list them and log their params.")

        parser.add_argument('--force-job-id',
                            dest='unique_job_id',
                            type=str,
                            default=None,
                            help='Forces the use of a particular job ID. Used '
                            'internally when interacting with an avocado '
                            'server. You should not use this option '
                            'unless you know exactly what you\'re doing')

        parser.add_argument('--job-results-dir',
                            action='store',
                            dest='logdir',
                            default=None,
                            metavar='DIRECTORY',
                            help=('Forces to use of an alternate job '
                                  'results directory.'))

        parser.add_argument('--job-timeout',
                            action='store',
                            default=None,
                            metavar='SECONDS',
                            help='Set the maximum amount of time (in SECONDS) '
                            'that tests are allowed to execute. '
                            'Values <= zero means "no timeout". '
                            'You can also use suffixes, like: '
                            ' s (seconds), m (minutes), h (hours). ')

        parser.add_argument('--failfast',
                            choices=('on', 'off'),
                            help='Enable or disable the job interruption on '
                            'first failed test.')

        sysinfo_default = settings.get_value('sysinfo.collect',
                                             'enabled',
                                             key_type='bool',
                                             default=True)
        sysinfo_default = 'on' if sysinfo_default is True else 'off'
        parser.add_argument('--sysinfo',
                            choices=('on', 'off'),
                            default=sysinfo_default,
                            help="Enable or disable "
                            "system information (hardware details, profilers, "
                            "etc.). Current:  %(default)s")

        parser.output = parser.add_argument_group('output and result format')

        parser.output.add_argument('-s',
                                   '--silent',
                                   action="store_true",
                                   default=argparse.SUPPRESS,
                                   help='Silence stdout')

        parser.output.add_argument('--show-job-log',
                                   action='store_true',
                                   default=False,
                                   help="Display only the job "
                                   "log on stdout. Useful for test debugging "
                                   "purposes. No output will be displayed if "
                                   "you also specify --silent")

        parser.output.add_argument("--store-logging-stream",
                                   nargs="*",
                                   default=[],
                                   metavar="STREAM[:LEVEL]",
                                   help="Store given logging STREAMs in "
                                   "$JOB_RESULTS_DIR/$STREAM.$LEVEL.")

        out_check = parser.add_argument_group('output check arguments')

        out_check.add_argument('--output-check-record',
                               choices=('none', 'all', 'stdout', 'stderr'),
                               default='none',
                               help="Record output streams of your tests "
                               "to reference files (valid options: none (do "
                               "not record output streams), all (record both "
                               "stdout and stderr), stdout (record only "
                               "stderr), stderr (record only stderr). "
                               'Current: %(default)s')

        out_check.add_argument('--output-check',
                               choices=('on', 'off'),
                               default='on',
                               help="Enable or disable test output (stdout/"
                               "stderr) check. If this option is off, no "
                               "output will be checked, even if there are "
                               "reference files present for the test. "
                               "Current: on (output check enabled)")

        loader.add_loader_options(parser)

        mux = parser.add_argument_group('test parameters')
        mux.add_argument('--filter-only',
                         nargs='*',
                         default=[],
                         help='Filter only path(s) from multiplexing')
        mux.add_argument('--filter-out',
                         nargs='*',
                         default=[],
                         help='Filter out path(s) from multiplexing')
        mux.add_argument('--mux-path',
                         nargs='*',
                         default=None,
                         help="List of paths used to determine path "
                         "priority when querying for parameters")
        mux.add_argument('--mux-inject',
                         default=[],
                         nargs='*',
                         help="Inject [path:]key:node values into the "
                         "final multiplex tree.")
Exemplo n.º 11
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        parser.add_argument('url', type=str, default=[], nargs='*',
                            help='List of test IDs (aliases or paths)')

        parser.add_argument("-d", "--dry-run", action="store_true",
                            help="Instead of running the test only "
                            "list them and log their params.")

        parser.add_argument('-z', '--archive', action='store_true', default=False,
                            help='Archive (ZIP) files generated by tests')

        parser.add_argument('--force-job-id', dest='unique_job_id',
                            type=str, default=None,
                            help=('Forces the use of a particular job ID. Used '
                                  'internally when interacting with an avocado '
                                  'server. You should not use this option '
                                  'unless you know exactly what you\'re doing'))

        parser.add_argument('--job-results-dir', action='store',
                            dest='logdir', default=None, metavar='DIRECTORY',
                            help=('Forces to use of an alternate job '
                                  'results directory.'))

        parser.add_argument('--job-timeout', action='store',
                            default=None, metavar='SECONDS',
                            help=('Set the maximum amount of time (in SECONDS) that '
                                  'tests are allowed to execute. '
                                  'Note that zero means "no timeout". '
                                  'You can also use suffixes, like: '
                                  ' s (seconds), m (minutes), h (hours). '))

        sysinfo_default = settings.get_value('sysinfo.collect',
                                             'enabled',
                                             key_type='bool',
                                             default=True)
        sysinfo_default = 'on' if sysinfo_default is True else 'off'
        parser.add_argument('--sysinfo', choices=('on', 'off'), default=sysinfo_default,
                            help=('Enable or disable system information '
                                  '(hardware details, profilers, etc.). '
                                  'Current:  %(default)s'))

        parser.output = parser.add_argument_group('output and result format')

        parser.output.add_argument(
            '-s', '--silent', action='store_true', default=False,
            help='Silence stdout')

        parser.output.add_argument(
            '--show-job-log', action='store_true', default=False,
            help=('Display only the job log on stdout. Useful '
                  'for test debugging purposes. No output will '
                  'be displayed if you also specify --silent'))

        out_check = parser.add_argument_group('output check arguments')

        out_check.add_argument('--output-check-record',
                               choices=('none', 'all', 'stdout', 'stderr'),
                               default='none',
                               help=('Record output streams of your tests '
                                     'to reference files (valid options: '
                                     'none (do not record output streams), '
                                     'all (record both stdout and stderr), '
                                     'stdout (record only stderr), '
                                     'stderr (record only stderr). '
                                     'Current: %(default)s'))

        out_check.add_argument('--output-check', choices=('on', 'off'),
                               default='on',
                               help=('Enable or disable test output (stdout/stderr) check. '
                                     'If this option is off, no output will '
                                     'be checked, even if there are reference files '
                                     'present for the test. '
                                     'Current: on (output check enabled)'))

        loader.add_loader_options(parser)

        if multiplexer.MULTIPLEX_CAPABLE:
            mux = parser.add_argument_group('multiplexer use on test execution')
            mux.add_argument('-m', '--multiplex-files', nargs='*',
                             default=None, metavar='FILE',
                             help='Location of one or more Avocado multiplex (.yaml) '
                             'FILE(s) (order dependent)')
            mux.add_argument('--filter-only', nargs='*', default=[],
                             help='Filter only path(s) from multiplexing')
            mux.add_argument('--filter-out', nargs='*', default=[],
                             help='Filter out path(s) from multiplexing')
            mux.add_argument('--mux-path', nargs='*', default=None,
                             help="List of paths used to determine path "
                             "priority when querying for parameters")
            mux.add_argument('--mux-inject', default=[], nargs='*',
                             help="Inject [path:]key:node values into the "
                             "final multiplex tree.")
Exemplo n.º 12
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super().configure(parser)

        settings.add_argparser_to_option(namespace='resolver.references',
                                         nargs='*',
                                         metavar='TEST_REFERENCE',
                                         parser=parser,
                                         positional_arg=True,
                                         long_arg=None,
                                         allow_multiple=True)

        help_msg = ('Parameter name and value to pass to all tests. This is '
                    'only applicable when not using a varianter plugin. '
                    'This option format must be given in the NAME=VALUE '
                    'format, and may be given any number of times, or per '
                    'parameter.')
        settings.register_option(section='run',
                                 key='test_parameters',
                                 action='append',
                                 default=[],
                                 key_type=self._test_parameter,
                                 metavar="NAME_VALUE",
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--test-parameter',
                                 short_arg='-p')

        settings.add_argparser_to_option(namespace='run.test_runner',
                                         parser=parser,
                                         long_arg='--test-runner',
                                         metavar='TEST_RUNNER')

        help_msg = ('Instead of running the test only list them and log '
                    'their params.')
        settings.register_option(section='run.dry_run',
                                 key='enabled',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 short_arg='-d',
                                 long_arg='--dry-run')

        help_msg = ('Do not automatically clean up temporary directories '
                    'used by dry-run')
        settings.register_option(section='run.dry_run',
                                 key='no_cleanup',
                                 help_msg=help_msg,
                                 default=False,
                                 key_type=bool,
                                 parser=parser,
                                 long_arg='--dry-run-no-cleanup')

        help_msg = ('Forces the use of a particular job ID. Used internally '
                    'when interacting with an avocado server. You should not '
                    'use this option unless you know exactly what you\'re '
                    'doing')
        settings.register_option(section='run',
                                 key='unique_job_id',
                                 default=None,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--force-job-id',
                                 metavar='UNIQUE_JOB_ID')

        help_msg = 'Forces to use of an alternate job results directory.'
        settings.register_option(section='run',
                                 key='results_dir',
                                 default=None,
                                 metavar='DIRECTORY',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--job-results-dir')

        help_msg = ('Categorizes this within a directory with the same name, '
                    'by creating a link to the job result directory')
        settings.register_option(section='run',
                                 key='job_category',
                                 help_msg=help_msg,
                                 parser=parser,
                                 default=None,
                                 metavar='CATEGORY',
                                 long_arg='--job-category')

        settings.add_argparser_to_option(namespace='job.run.timeout',
                                         metavar='SECONDS',
                                         parser=parser,
                                         long_arg='--job-timeout')

        help_msg = 'Enable the job interruption on first failed test.'
        settings.register_option(section='run',
                                 key='failfast',
                                 default=False,
                                 key_type=bool,
                                 action='store_true',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--failfast')

        help_msg = 'Keep job temporary files (useful for avocado debugging).'
        settings.register_option(section='run',
                                 key='keep_tmp',
                                 default=False,
                                 key_type=bool,
                                 action='store_true',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--keep-tmp')

        help_msg = ('Force the job execution, even if some of the test '
                    'references are not resolved to tests.')
        settings.register_option(section='run',
                                 key='ignore_missing_references',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--ignore-missing-references')

        settings.add_argparser_to_option(namespace='sysinfo.collect.enabled',
                                         parser=parser,
                                         action='store_false',
                                         long_arg='--disable-sysinfo')

        settings.add_argparser_to_option('run.execution_order',
                                         parser=parser,
                                         long_arg='--execution-order')

        parser.output = parser.add_argument_group('output and result format')

        settings.add_argparser_to_option(
            'job.run.store_logging_stream',
            parser=parser.output,
            long_arg='--store-logging-stream',
            metavar='LOGGING_STREAM',
            argparse_type=lambda x: set(x.split(',')))

        help_msg = ('Logs the possible data directories for each test. This '
                    'is helpful when writing new tests and not being sure '
                    'where to put data files. Look for "Test data '
                    'directories" in your test log')
        settings.register_option(section='run',
                                 key='log_test_data_directories',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--log-test-data-directories')

        loader.add_loader_options(parser, 'run')
        parser_common_args.add_tag_filter_args(parser)
Exemplo n.º 13
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: The Avocado command line application parser
        :type parser: :class:`avocado.core.parser.ArgumentParser`
        """
        parser = super(List, self).configure(parser)
        help_msg = ('List of test references (aliases or paths). If empty, '
                    'Avocado will list tests on the configured test source, '
                    '(see "avocado config --datadir") Also, if there are '
                    'other test loader plugins active, tests from those '
                    'plugins might also show up (behavior may vary among '
                    'plugins)')
        settings.register_option(section='list',
                                 key='references',
                                 default=[],
                                 nargs='*',
                                 key_type=list,
                                 help_msg=help_msg,
                                 parser=parser,
                                 positional_arg=True)
        loader.add_loader_options(parser, 'list')

        help_msg = ('Uses the Avocado resolver method (part of the nrunner '
                    'architecture) to detect tests. This is enabled by '
                    'default and exists only for compatibility purposes, '
                    'and will be removed soon. To use the legacy (loader) '
                    'method for finding tests, set the "--loader" option')
        settings.register_option(section='list',
                                 key='compatiblity_with_resolver_noop',
                                 key_type=bool,
                                 default=True,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--resolver')

        help_msg = ('Uses the Avocado legacy (loader) method for finding '
                    'tests. This option will exist only for a transitional '
                    'period until the legacy (loader) method is deprecated '
                    'and removed')
        settings.register_option(section='list',
                                 key='resolver',
                                 key_type=bool,
                                 default=True,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--loader')

        help_msg = ('Writes runnable recipe files to a directory. Valid only '
                    'when using --resolver.')
        settings.register_option(section='list.recipes',
                                 key='write_to_directory',
                                 default=None,
                                 metavar='DIRECTORY',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--write-recipes-to-directory')

        help_msg = 'Writes output to a json file.'
        settings.register_option(section='list',
                                 key='write_to_json_file',
                                 default=None,
                                 metavar='JSON_FILE',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--json')

        parser_common_args.add_tag_filter_args(parser)
Exemplo n.º 14
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        parser.add_argument('url', type=str, default=[], nargs='*',
                            help='List of test IDs (aliases or paths)')

        parser.add_argument("-d", "--dry-run", action="store_true",
                            help="Instead of running the test only "
                            "list them and log their params.")

        parser.add_argument('-z', '--archive', action='store_true', default=False,
                            help='Archive (ZIP) files generated by tests')

        parser.add_argument('--force-job-id', dest='unique_job_id',
                            type=str, default=None,
                            help=('Forces the use of a particular job ID. Used '
                                  'internally when interacting with an avocado '
                                  'server. You should not use this option '
                                  'unless you know exactly what you\'re doing'))

        parser.add_argument('--job-results-dir', action='store',
                            dest='logdir', default=None, metavar='DIRECTORY',
                            help=('Forces to use of an alternate job '
                                  'results directory.'))

        parser.add_argument('--job-timeout', action='store',
                            default=None, metavar='SECONDS',
                            help=('Set the maximum amount of time (in SECONDS) that '
                                  'tests are allowed to execute. '
                                  'Note that zero means "no timeout". '
                                  'You can also use suffixes, like: '
                                  ' s (seconds), m (minutes), h (hours). '))

        sysinfo_default = settings.get_value('sysinfo.collect',
                                             'enabled',
                                             key_type='bool',
                                             default=True)
        sysinfo_default = 'on' if sysinfo_default is True else 'off'
        parser.add_argument('--sysinfo', choices=('on', 'off'), default=sysinfo_default,
                            help=('Enable or disable system information '
                                  '(hardware details, profilers, etc.). '
                                  'Current:  %(default)s'))

        parser.output = parser.add_argument_group('output and result format')

        parser.output.add_argument(
            '-s', '--silent', action="store_true", default=argparse.SUPPRESS,
            help='Silence stdout')

        parser.output.add_argument(
            '--show-job-log', action='store_true', default=False,
            help=('Display only the job log on stdout. Useful '
                  'for test debugging purposes. No output will '
                  'be displayed if you also specify --silent'))

        parser.output.add_argument("--store-logging-stream", nargs="*",
                                   default=[], metavar="STREAM[:LEVEL]",
                                   help="Store given logging STREAMs in "
                                   "$JOB_RESULTS_DIR/$STREAM.$LEVEL.")

        out_check = parser.add_argument_group('output check arguments')

        out_check.add_argument('--output-check-record',
                               choices=('none', 'all', 'stdout', 'stderr'),
                               default='none',
                               help=('Record output streams of your tests '
                                     'to reference files (valid options: '
                                     'none (do not record output streams), '
                                     'all (record both stdout and stderr), '
                                     'stdout (record only stderr), '
                                     'stderr (record only stderr). '
                                     'Current: %(default)s'))

        out_check.add_argument('--output-check', choices=('on', 'off'),
                               default='on',
                               help=('Enable or disable test output (stdout/stderr) check. '
                                     'If this option is off, no output will '
                                     'be checked, even if there are reference files '
                                     'present for the test. '
                                     'Current: on (output check enabled)'))

        loader.add_loader_options(parser)

        if multiplexer.MULTIPLEX_CAPABLE:
            mux = parser.add_argument_group('multiplexer use on test execution')
            mux.add_argument('-m', '--multiplex', nargs='*', dest='multiplex_files',
                             default=None, metavar='FILE',
                             help='Location of one or more Avocado multiplex (.yaml) '
                             'FILE(s) (order dependent)')
            mux.add_argument('--multiplex-files', nargs='*',
                             default=None, metavar='FILE',
                             help='DEPRECATED: please use --multiplex instead')
            mux.add_argument('--filter-only', nargs='*', default=[],
                             help='Filter only path(s) from multiplexing')
            mux.add_argument('--filter-out', nargs='*', default=[],
                             help='Filter out path(s) from multiplexing')
            mux.add_argument('--mux-path', nargs='*', default=None,
                             help="List of paths used to determine path "
                             "priority when querying for parameters")
            mux.add_argument('--mux-inject', default=[], nargs='*',
                             help="Inject [path:]key:node values into the "
                             "final multiplex tree.")
Exemplo n.º 15
0
    def configure(self, parser):
        """
        Add the subparser for the list action.

        :param parser: The Avocado command line application parser
        :type parser: :class:`avocado.core.parser.ArgumentParser`
        """
        parser = super(List, self).configure(parser)
        settings.add_argparser_to_option(namespace='resolver.references',
                                         nargs='*',
                                         metavar='TEST_REFERENCE',
                                         parser=parser,
                                         positional_arg=True,
                                         long_arg=None,
                                         allow_multiple=True)
        loader.add_loader_options(parser, 'list')

        help_msg = ('Uses the Avocado resolver method (part of the nrunner '
                    'architecture) to detect tests. This is enabled by '
                    'default and exists only for compatibility purposes, '
                    'and will be removed soon. To use the legacy (loader) '
                    'method for finding tests, set the "--loader" option')
        settings.register_option(section='list',
                                 key='compatiblity_with_resolver_noop',
                                 key_type=bool,
                                 default=True,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--resolver')

        help_msg = ('Uses the Avocado legacy (loader) method for finding '
                    'tests. This option will exist only for a transitional '
                    'period until the legacy (loader) method is deprecated '
                    'and removed')
        settings.register_option(section='list',
                                 key='resolver',
                                 key_type=bool,
                                 default=True,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--loader')

        help_msg = ('Writes runnable recipe files to a directory. Valid only '
                    'when using --resolver.')
        settings.register_option(section='list.recipes',
                                 key='write_to_directory',
                                 default=None,
                                 metavar='DIRECTORY',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--write-recipes-to-directory')

        help_msg = 'Writes output to a json file.'
        settings.register_option(section='list',
                                 key='write_to_json_file',
                                 default=None,
                                 metavar='JSON_FILE',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--json')

        parser_common_args.add_tag_filter_args(parser)
Exemplo n.º 16
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        parser.add_argument("reference",
                            type=str,
                            default=[],
                            nargs='*',
                            metavar="TEST_REFERENCE",
                            help='List of test references (aliases or paths)')

        parser.add_argument("-p",
                            "--test-parameter",
                            action="append",
                            dest='test_parameters',
                            default=[],
                            metavar="NAME_VALUE",
                            type=self._test_parameter,
                            help="Parameter name and value to pass to all "
                            "tests. This is only applicable when not using a "
                            "varianter plugin. This option format must be "
                            "given in the NAME=VALUE format, and may be given "
                            "any number of times, or per parameter.")

        parser.add_argument("-d",
                            "--dry-run",
                            action="store_true",
                            help="Instead of running the test only "
                            "list them and log their params.")

        parser.add_argument("--dry-run-no-cleanup",
                            action="store_true",
                            help="Do not automatically clean up temporary "
                            "directories used by dry-run",
                            default=False)

        parser.add_argument('--force-job-id',
                            dest='unique_job_id',
                            type=str,
                            default=None,
                            help='Forces the use of a particular job ID. Used '
                            'internally when interacting with an avocado '
                            'server. You should not use this option '
                            'unless you know exactly what you\'re doing')

        parser.add_argument('--job-results-dir',
                            action='store',
                            dest='base_logdir',
                            default=None,
                            metavar='DIRECTORY',
                            help=('Forces to use of an alternate job '
                                  'results directory.'))

        parser.add_argument('--job-timeout',
                            action='store',
                            default=None,
                            metavar='SECONDS',
                            help='Set the maximum amount of time (in SECONDS) '
                            'that tests are allowed to execute. '
                            'Values <= zero means "no timeout". '
                            'You can also use suffixes, like: '
                            ' s (seconds), m (minutes), h (hours). ')

        parser.add_argument('--failfast',
                            choices=('on', 'off'),
                            help='Enable or disable the job interruption on '
                            'first failed test.')

        parser.add_argument('--keep-tmp',
                            choices=('on', 'off'),
                            default='off',
                            help='Keep job temporary files '
                            '(useful for avocado debugging). Defaults to off.')

        parser.add_argument('--ignore-missing-references',
                            choices=('on', 'off'),
                            help="Force the job execution, even if some of "
                            "the test references are not resolved to tests.")

        sysinfo_default = settings.get_value('sysinfo.collect',
                                             'enabled',
                                             key_type='bool',
                                             default=True)
        sysinfo_default = 'on' if sysinfo_default is True else 'off'
        parser.add_argument('--sysinfo',
                            choices=('on', 'off'),
                            default=sysinfo_default,
                            help="Enable or disable "
                            "system information (hardware details, profilers, "
                            "etc.). Current:  %(default)s")

        parser.add_argument("--execution-order",
                            choices=("tests-per-variant", "variants-per-test"),
                            help="Defines the order of iterating through test "
                            "suite and test variants")

        parser.output = parser.add_argument_group('output and result format')

        parser.output.add_argument('-s',
                                   '--silent',
                                   action="store_true",
                                   default=argparse.SUPPRESS,
                                   help='Silence stdout')

        parser.output.add_argument('--show-job-log',
                                   action='store_true',
                                   default=False,
                                   help="Display only the job "
                                   "log on stdout. Useful for test debugging "
                                   "purposes. No output will be displayed if "
                                   "you also specify --silent")

        parser.output.add_argument("--store-logging-stream",
                                   nargs="*",
                                   default=[],
                                   metavar="STREAM[:LEVEL]",
                                   help="Store given logging STREAMs in "
                                   "$JOB_RESULTS_DIR/$STREAM.$LEVEL.")

        parser.output.add_argument("--log-test-data-directories",
                                   action="store_true",
                                   help="Logs the possible data directories "
                                   "for each test. This is helpful when "
                                   "writing new tests and not being sure "
                                   "where to put data files. Look for \""
                                   "Test data directories\" in your test log")

        out_check = parser.add_argument_group('output check arguments')

        out_check.add_argument('--output-check-record',
                               choices=('none', 'stdout', 'stderr', 'both',
                                        'combined', 'all'),
                               help="Record the output produced by each test "
                               "(from stdout and stderr) into both the "
                               "current executing result and into  "
                               "reference files.  Reference files are "
                               "used on subsequent runs to determine if "
                               "the test produced the expected output or "
                               "not, and the current executing result is "
                               "used to check against a previously "
                               "recorded reference file.  Valid values: "
                               "'none' (to explicitly disable all "
                               "recording) 'stdout' (to record standard "
                               "output *only*), 'stderr' (to record "
                               "standard error *only*), 'both' (to record"
                               " standard output and error in separate "
                               "files), 'combined' (for standard output "
                               "and error in a single file). 'all' is "
                               "also a valid but deprecated option that "
                               "is a synonym of 'both'.  This option "
                               "does not have a default value, but the "
                               "Avocado test runner will record the "
                               "test under execution in the most suitable"
                               " way unless it's explicitly disabled with"
                               " value 'none'")

        out_check.add_argument('--output-check',
                               choices=('on', 'off'),
                               default='on',
                               help="Enable or disable test output (stdout/"
                               "stderr) check. If this option is off, no "
                               "output will be checked, even if there are "
                               "reference files present for the test. "
                               "Current: on (output check enabled)")

        loader.add_loader_options(parser)

        filtering = parser.add_argument_group('filtering parameters')
        filtering.add_argument('-t',
                               '--filter-by-tags',
                               metavar='TAGS',
                               action='append',
                               help='Filter INSTRUMENTED tests based on '
                               '":avocado: tags=tag1,tag2" notation in '
                               'their class docstring')
        filtering.add_argument('--filter-by-tags-include-empty',
                               action='store_true',
                               default=False,
                               help=('Include all tests without tags during '
                                     'filtering. This effectively means they '
                                     'will be kept in the test suite found '
                                     'previously to filtering.'))
        filtering.add_argument('--filter-by-tags-include-empty-key',
                               action='store_true',
                               default=False,
                               help=('Include all tests that do not have a '
                                     'matching key in its key:val tags. This '
                                     'effectively means those tests will be '
                                     'kept in the test suite found previously '
                                     'to filtering.'))
Exemplo n.º 17
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        parser.add_argument("reference", type=str, default=[], nargs='*',
                            metavar="TEST_REFERENCE",
                            help='List of test references (aliases or paths)')

        parser.add_argument("-p", "--test-parameter", action="append",
                            dest='test_parameters', default=[],
                            metavar="NAME_VALUE", type=self._test_parameter,
                            help="Parameter name and value to pass to all "
                            "tests. This is only applicable when not using a "
                            "varianter plugin. This option format must be "
                            "given in the NAME=VALUE format, and may be given "
                            "any number of times, or per parameter.")

        parser.add_argument("-d", "--dry-run", action="store_true",
                            help="Instead of running the test only "
                            "list them and log their params.")

        parser.add_argument("--dry-run-no-cleanup", action="store_true",
                            help="Do not automatically clean up temporary "
                            "directories used by dry-run", default=False)

        parser.add_argument('--force-job-id', dest='unique_job_id',
                            type=str, default=None,
                            help='Forces the use of a particular job ID. Used '
                            'internally when interacting with an avocado '
                            'server. You should not use this option '
                            'unless you know exactly what you\'re doing')

        parser.add_argument('--job-results-dir', action='store',
                            dest='base_logdir', default=None, metavar='DIRECTORY',
                            help=('Forces to use of an alternate job '
                                  'results directory.'))

        parser.add_argument('--job-timeout', action='store',
                            default=None, metavar='SECONDS',
                            help='Set the maximum amount of time (in SECONDS) '
                            'that tests are allowed to execute. '
                            'Values <= zero means "no timeout". '
                            'You can also use suffixes, like: '
                            ' s (seconds), m (minutes), h (hours). ')

        parser.add_argument('--failfast', choices=('on', 'off'),
                            help='Enable or disable the job interruption on '
                            'first failed test.')

        parser.add_argument('--keep-tmp', choices=('on', 'off'),
                            default='off', help='Keep job temporary files '
                            '(useful for avocado debugging). Defaults to off.')

        parser.add_argument('--ignore-missing-references', choices=('on', 'off'),
                            help="Force the job execution, even if some of "
                            "the test references are not resolved to tests.")

        sysinfo_default = settings.get_value('sysinfo.collect',
                                             'enabled',
                                             key_type='bool',
                                             default=True)
        sysinfo_default = 'on' if sysinfo_default is True else 'off'
        parser.add_argument('--sysinfo', choices=('on', 'off'),
                            default=sysinfo_default, help="Enable or disable "
                            "system information (hardware details, profilers, "
                            "etc.). Current:  %(default)s")

        parser.add_argument("--execution-order",
                            choices=("tests-per-variant",
                                     "variants-per-test"),
                            help="Defines the order of iterating through test "
                            "suite and test variants")

        parser.output = parser.add_argument_group('output and result format')

        parser.output.add_argument('-s', '--silent', action="store_true",
                                   default=argparse.SUPPRESS,
                                   help='Silence stdout')

        parser.output.add_argument('--show-job-log', action='store_true',
                                   default=False, help="Display only the job "
                                   "log on stdout. Useful for test debugging "
                                   "purposes. No output will be displayed if "
                                   "you also specify --silent")

        parser.output.add_argument("--store-logging-stream", nargs="*",
                                   default=[], metavar="STREAM[:LEVEL]",
                                   help="Store given logging STREAMs in "
                                   "$JOB_RESULTS_DIR/$STREAM.$LEVEL.")

        parser.output.add_argument("--log-test-data-directories",
                                   action="store_true",
                                   help="Logs the possible data directories "
                                   "for each test. This is helpful when "
                                   "writing new tests and not being sure "
                                   "where to put data files. Look for \""
                                   "Test data directories\" in your test log")

        out_check = parser.add_argument_group('output check arguments')

        out_check.add_argument('--output-check-record',
                               choices=('none', 'stdout', 'stderr',
                                        'both', 'combined', 'all'),
                               help="Record the output produced by each test "
                                    "(from stdout and stderr) into both the "
                                    "current executing result and into  "
                                    "reference files.  Reference files are "
                                    "used on subsequent runs to determine if "
                                    "the test produced the expected output or "
                                    "not, and the current executing result is "
                                    "used to check against a previously "
                                    "recorded reference file.  Valid values: "
                                    "'none' (to explicitly disable all "
                                    "recording) 'stdout' (to record standard "
                                    "output *only*), 'stderr' (to record "
                                    "standard error *only*), 'both' (to record"
                                    " standard output and error in separate "
                                    "files), 'combined' (for standard output "
                                    "and error in a single file). 'all' is "
                                    "also a valid but deprecated option that "
                                    "is a synonym of 'both'.  This option "
                                    "does not have a default value, but the "
                                    "Avocado test runner will record the "
                                    "test under execution in the most suitable"
                                    " way unless it's explicitly disabled with"
                                    " value 'none'")

        out_check.add_argument('--output-check', choices=('on', 'off'),
                               default='on',
                               help="Enable or disable test output (stdout/"
                               "stderr) check. If this option is off, no "
                               "output will be checked, even if there are "
                               "reference files present for the test. "
                               "Current: on (output check enabled)")

        loader.add_loader_options(parser)

        filtering = parser.add_argument_group('filtering parameters')
        filtering.add_argument('-t', '--filter-by-tags', metavar='TAGS',
                               action='append',
                               help='Filter INSTRUMENTED tests based on '
                               '":avocado: tags=tag1,tag2" notation in '
                               'their class docstring')
        filtering.add_argument('--filter-by-tags-include-empty',
                               action='store_true', default=False,
                               help=('Include all tests without tags during '
                                     'filtering. This effectively means they '
                                     'will be kept in the test suite found '
                                     'previously to filtering.'))
        filtering.add_argument('--filter-by-tags-include-empty-key',
                               action='store_true', default=False,
                               help=('Include all tests that do not have a '
                                     'matching key in its key:val tags. This '
                                     'effectively means those tests will be '
                                     'kept in the test suite found previously '
                                     'to filtering.'))
Exemplo n.º 18
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        parser.add_argument("reference", type=str, default=[], nargs='*',
                            metavar="TEST_REFERENCE",
                            help='List of test references (aliases or paths)')

        parser.add_argument("-d", "--dry-run", action="store_true",
                            help="Instead of running the test only "
                            "list them and log their params.")

        parser.add_argument('--force-job-id', dest='unique_job_id',
                            type=str, default=None,
                            help='Forces the use of a particular job ID. Used '
                            'internally when interacting with an avocado '
                            'server. You should not use this option '
                            'unless you know exactly what you\'re doing')

        parser.add_argument('--job-results-dir', action='store',
                            dest='base_logdir', default=None, metavar='DIRECTORY',
                            help=('Forces to use of an alternate job '
                                  'results directory.'))

        parser.add_argument('--job-timeout', action='store',
                            default=None, metavar='SECONDS',
                            help='Set the maximum amount of time (in SECONDS) '
                            'that tests are allowed to execute. '
                            'Values <= zero means "no timeout". '
                            'You can also use suffixes, like: '
                            ' s (seconds), m (minutes), h (hours). ')

        parser.add_argument('--failfast', choices=('on', 'off'),
                            help='Enable or disable the job interruption on '
                            'first failed test.')

        parser.add_argument('--keep-tmp', choices=('on', 'off'),
                            default='off', help='Keep job temporary files '
                            '(useful for avocado debugging). Defaults to off.')

        parser.add_argument('--ignore-missing-references', choices=('on', 'off'),
                            help="Force the job execution, even if some of "
                            "the test references are not resolved to tests.")

        sysinfo_default = settings.get_value('sysinfo.collect',
                                             'enabled',
                                             key_type='bool',
                                             default=True)
        sysinfo_default = 'on' if sysinfo_default is True else 'off'
        parser.add_argument('--sysinfo', choices=('on', 'off'),
                            default=sysinfo_default, help="Enable or disable "
                            "system information (hardware details, profilers, "
                            "etc.). Current:  %(default)s")

        parser.add_argument("--execution-order",
                            choices=("tests-per-variant",
                                     "variants-per-test"),
                            help="Defines the order of iterating through test "
                            "suite and test variants")

        parser.output = parser.add_argument_group('output and result format')

        parser.output.add_argument('-s', '--silent', action="store_true",
                                   default=argparse.SUPPRESS,
                                   help='Silence stdout')

        parser.output.add_argument('--show-job-log', action='store_true',
                                   default=False, help="Display only the job "
                                   "log on stdout. Useful for test debugging "
                                   "purposes. No output will be displayed if "
                                   "you also specify --silent")

        parser.output.add_argument("--store-logging-stream", nargs="*",
                                   default=[], metavar="STREAM[:LEVEL]",
                                   help="Store given logging STREAMs in "
                                   "$JOB_RESULTS_DIR/$STREAM.$LEVEL.")

        parser.output.add_argument("--log-test-data-directories",
                                   action="store_true",
                                   help="Logs the possible data directories "
                                   "for each test. This is helpful when "
                                   "writing new tests and not being sure "
                                   "where to put data files. Look for \""
                                   "Test data directories\" in your test log")

        out_check = parser.add_argument_group('output check arguments')

        out_check.add_argument('--output-check-record',
                               choices=('none', 'all', 'stdout', 'stderr'),
                               default='none',
                               help="Record output streams of your tests "
                               "to reference files (valid options: none (do "
                               "not record output streams), all (record both "
                               "stdout and stderr), stdout (record only "
                               "stderr), stderr (record only stderr). "
                               'Current: %(default)s')

        out_check.add_argument('--output-check', choices=('on', 'off'),
                               default='on',
                               help="Enable or disable test output (stdout/"
                               "stderr) check. If this option is off, no "
                               "output will be checked, even if there are "
                               "reference files present for the test. "
                               "Current: on (output check enabled)")

        loader.add_loader_options(parser)

        filtering = parser.add_argument_group('filtering parameters')
        filtering.add_argument('-t', '--filter-by-tags', metavar='TAGS',
                               action='append',
                               help='Filter INSTRUMENTED tests based on '
                               '":avocado: tags=tag1,tag2" notation in '
                               'their class docstring')
        filtering.add_argument('--filter-by-tags-include-empty',
                               action='store_true', default=False,
                               help=('Include all tests without tags during '
                                     'filtering. This effectively means they '
                                     'will be kept in the test suite found '
                                     'previously to filtering.'))
Exemplo n.º 19
0
    def configure(self, parser):
        """
        Add the subparser for the run action.

        :param parser: Main test runner parser.
        """
        parser = super(Run, self).configure(parser)

        help_msg = 'List of test references (aliases or paths)'
        settings.register_option(section='run',
                                 key='references',
                                 key_type=list,
                                 default=[],
                                 nargs='*',
                                 metavar='TEST_REFERENCE',
                                 parser=parser,
                                 help_msg=help_msg,
                                 positional_arg=True)

        help_msg = ('Parameter name and value to pass to all tests. This is '
                    'only applicable when not using a varianter plugin. '
                    'This option format must be given in the NAME=VALUE '
                    'format, and may be given any number of times, or per '
                    'parameter.')
        settings.register_option(section='run',
                                 key='test_parameters',
                                 action='append',
                                 default=[],
                                 key_type=self._test_parameter,
                                 metavar="NAME_VALUE",
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--test-parameter',
                                 short_arg='-p')

        help_msg = ('Instead of running the test only list them and log '
                    'their params.')
        settings.register_option(section='run.dry_run',
                                 key='enabled',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 short_arg='-d',
                                 long_arg='--dry-run')

        help_msg = ('Do not automatically clean up temporary directories '
                    'used by dry-run')
        settings.register_option(section='run.dry_run',
                                 key='no_cleanup',
                                 help_msg=help_msg,
                                 default=False,
                                 key_type=bool,
                                 parser=parser,
                                 long_arg='--dry-run-no-cleanup')

        help_msg = ('Forces the use of a particular job ID. Used internally '
                    'when interacting with an avocado server. You should not '
                    'use this option unless you know exactly what you\'re '
                    'doing')
        settings.register_option(section='run',
                                 key='unique_job_id',
                                 default=None,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--force-job-id')

        help_msg = 'Forces to use of an alternate job results directory.'
        settings.register_option(section='run',
                                 key='results_dir',
                                 default=None,
                                 metavar='DIRECTORY',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--job-results-dir')

        help_msg = ('Categorizes this within a directory with the same name, '
                    'by creating a link to the job result directory')
        settings.register_option(section='run',
                                 key='job_category',
                                 help_msg=help_msg,
                                 parser=parser,
                                 default=None,
                                 metavar='CATEGORY',
                                 long_arg='--job-category')

        help_msg = ('Set the maximum amount of time (in SECONDS) that tests '
                    'are allowed to execute. Values <= zero means "no '
                    'timeout". You can also use suffixes, like: s (seconds), '
                    'm (minutes), h (hours). ')
        settings.register_option(section='run',
                                 key='job_timeout',
                                 help_msg=help_msg,
                                 default='0',
                                 metavar='SECONDS',
                                 parser=parser,
                                 long_arg='--job-timeout')

        help_msg = ('Enable or disable the job interruption on first failed '
                    'test. "on" and "off" will be deprecated soon.')
        settings.register_option(section='run',
                                 key='failfast',
                                 choices=('on', 'off'),
                                 default='off',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--failfast')

        help_msg = ('Keep job temporary files (useful for avocado debugging). '
                    '"on" and "off" will be deprecated soon.')
        settings.register_option(section='run',
                                 key='keep_tmp',
                                 choices=('on', 'off'),
                                 default='off',
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--keep-tmp')

        help_msg = ('Force the job execution, even if some of the test '
                    'references are not resolved to tests. "on" and '
                    '"off" will be deprecated soon.')
        settings.register_option(section='run',
                                 key='ignore_missing_references',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--ignore-missing-references')

        help_msg = ('Enable or disable sysinfo information. Like hardware '
                    'details, profiles, etc.')
        settings.register_option(section='sysinfo.collect',
                                 key='enabled',
                                 default='on',
                                 key_type=str,
                                 help_msg=help_msg,
                                 choices=('on', 'off'),
                                 parser=parser,
                                 short_arg='-S',
                                 long_arg='--sysinfo')

        help_msg = ('Defines the order of iterating through test suite '
                    'and test variants')
        settings.register_option(section='run',
                                 key='execution_order',
                                 choices=('tests-per-variant',
                                          'variants-per-test'),
                                 default=None,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--execution-order')

        parser.output = parser.add_argument_group('output and result format')

        help_msg = ('Store given logging STREAMs in '
                    '"$JOB_RESULTS_DIR/$STREAM.$LEVEL."')
        settings.register_option(section='run',
                                 key='store_logging_stream',
                                 nargs='*',
                                 help_msg=help_msg,
                                 default=[],
                                 metavar='STREAM[:LEVEL]',
                                 key_type=list,
                                 parser=parser,
                                 long_arg='--store-logging-stream')

        help_msg = ('Logs the possible data directories for each test. This '
                    'is helpful when writing new tests and not being sure '
                    'where to put data files. Look for "Test data '
                    'directories" in your test log')
        settings.register_option(section='run',
                                 key='log_test_data_directories',
                                 default=False,
                                 key_type=bool,
                                 help_msg=help_msg,
                                 parser=parser,
                                 long_arg='--log-test-data-directories')

        out_check = parser.add_argument_group('output check arguments')

        help_msg = ('Record the output produced by each test (from stdout '
                    'and stderr) into both the current executing result '
                    'and into reference files. Reference files are used on '
                    'subsequent runs to determine if the test produced the '
                    'expected output or not, and the current executing result '
                    'is used to check against a previously recorded reference '
                    'file.  Valid values: "none" (to explicitly disable all '
                    'recording) "stdout" (to record standard output *only*), '
                    '"stderr" (to record standard error *only*), "both" (to '
                    'record standard output and error in separate files), '
                    '"combined" (for standard output and error in a single '
                    'file). "all" is also a valid but deprecated option that '
                    'is a synonym of "both".')
        settings.register_option(section='run',
                                 key='output_check_record',
                                 help_msg=help_msg,
                                 choices=('none', 'stdout', 'stderr', 'both',
                                          'combined', 'all'),
                                 parser=parser,
                                 default=None,
                                 long_arg='--output-check-record')

        help_msg = ('Enable or disable test output (stdout/stderr) check. If '
                    'this option is off, no output will be checked, even if '
                    'there are reference files present for the test. "on" '
                    'and "off" will be deprecated soon.')
        settings.register_option(section='run',
                                 key='output_check',
                                 default='on',
                                 choices=('on', 'off'),
                                 help_msg=help_msg,
                                 parser=out_check,
                                 long_arg='--output-check')

        loader.add_loader_options(parser)
        parser_common_args.add_tag_filter_args(parser)