Exemplo n.º 1
0
 def _handle_deprecated_exit_for_loop(self, error):
     if self._get(error, 'EXIT_FOR_LOOP'):
         from robot.output import LOGGER
         LOGGER.warn("Support for using 'ROBOT_EXIT_FOR_LOOP' attribute to "
                     "exit for loops is deprecated in Robot Framework 2.8 "
                     "and will be removed in 2.9.")
         raise ExitForLoop
Exemplo n.º 2
0
 def _handle_deprecated_exit_for_loop(self, error):
     if self._get(error, 'EXIT_FOR_LOOP'):
         from robot.output import LOGGER
         LOGGER.warn("Support for using 'ROBOT_EXIT_FOR_LOOP' attribute to "
                     "exit for loops is deprecated in Robot Framework 2.8 "
                     "and will be removed in 2.9.")
         raise ExitForLoop
Exemplo n.º 3
0
def _get_multisource_suite(datasources, include_suites, warn_on_skipped):
    suitedatas = []
    for datasource in datasources:
        try:
            suitedatas.append(_parse_suite(datasource, include_suites, warn_on_skipped))
        except DataError, err:
            LOGGER.warn(err)
Exemplo n.º 4
0
Arquivo: model.py Projeto: nbbull/RIDE
def _get_multisource_suite(datasources, include_suites, warn_on_skipped):
    suitedatas = []
    for datasource in datasources:
        try:
            suitedatas.append(_parse_suite(datasource, include_suites, warn_on_skipped))
        except DataError, err:
            LOGGER.warn(err)
Exemplo n.º 5
0
 def _deprecate_quoting(self, cell, path, line_number):
     if len(cell) > 1 and cell[0] == cell[-1] == '"':
         LOGGER.warn("TSV file '%s' has quotes around cells which is "
                     "deprecated and must be fixed. Remove quotes "
                     "from '%s' on line %d." % (path, cell, line_number))
         return cell[1:-1].replace('""', '"').strip()
     return cell
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     if settings['Critical'] or settings['NonCritical']:
         LOGGER.warn("Command line options --critical and --noncritical have been "
                     "deprecated. Use --skiponfailure instead.")
     if settings['XUnitSkipNonCritical']:
         LOGGER.warn("Command line option --xunitskipnoncritical has been "
                     "deprecated and has no effect.")
     LOGGER.info('Settings:\n%s' % unic(settings))
     builder = TestSuiteBuilder(settings['SuiteNames'],
                                included_extensions=settings.extension,
                                rpa=settings.rpa,
                                allow_empty_suite=settings.run_empty_suite)
     suite = builder.build(*datasources)
     settings.rpa = suite.rpa
     if settings.pre_run_modifiers:
         suite.visit(ModelModifier(settings.pre_run_modifiers,
                                   settings.run_empty_suite, LOGGER))
     suite.configure(**settings.suite_config)
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         old_max_error_lines = text.MAX_ERROR_LINES
         text.MAX_ERROR_LINES = settings.max_error_lines
         try:
             result = suite.run(settings)
         finally:
             text.MAX_ERROR_LINES = old_max_error_lines
         LOGGER.info("Tests execution ended. Statistics:\n%s"
                     % result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(settings.output if settings.log
                                   else result)
             writer.write_results(settings.get_rebot_settings())
     return result.return_code
Exemplo n.º 7
0
    def _get_variable(self, var):
        """'var' is an instance of a VariableSplitter"""
        # 1) Handle reserved syntax
        if var.identifier not in ['$','@','%']:
            value = '%s{%s}' % (var.identifier, var.base)
            LOGGER.warn("Syntax '%s' is reserved for future use. Please "
                        "escape it like '\\%s'." % (value, value))
            return value

        # 2) Handle environment variables
        elif var.identifier == '%':
            try:
                name = var.get_replaced_base(self).strip()
                if name != '':
                    return os.environ[name]
                else:
                    return '%%{%s}' % var.base
            except KeyError:
                raise DataError("Environment variable '%s' does not exist"
                                % name)

        # 3) Handle ${scalar} variables and @{list} variables without index
        elif var.index is None:
            name = '%s{%s}' % (var.identifier, var.get_replaced_base(self))
            return self[name]

        # 4) Handle items from list variables e.g. @{var}[1]
        else:
            try:
                index = int(self.replace_string(var.index))
                name = '@{%s}' % var.get_replaced_base(self)
                return self[name][index]
            except (ValueError, DataError, IndexError):
                raise DataError("Non-existing variable '@{%s}[%s]'"
                                % (var.base, var.index))
    def _get_variable(self, var):
        """'var' is an instance of a VariableSplitter"""
        # 1) Handle reserved syntax
        if var.identifier not in "$@%":
            value = "%s{%s}" % (var.identifier, var.base)
            LOGGER.warn("Syntax '%s' is reserved for future use. Please " "escape it like '\\%s'." % (value, value))
            return value

        # 2) Handle environment variables and Java system properties
        elif var.identifier == "%":
            name = var.get_replaced_base(self).strip()
            if not name:
                return "%%{%s}" % var.base
            value = utils.get_env_var(name)
            if value is not None:
                return value
            value = getJavaSystemProperty(name)
            if value is not None:
                return value
            raise DataError("Environment variable '%s' does not exist" % name)

        # 3) Handle ${scalar} variables and @{list} variables without index
        elif var.index is None:
            name = "%s{%s}" % (var.identifier, var.get_replaced_base(self))
            return self[name]

        # 4) Handle items from list variables e.g. @{var}[1]
        else:
            try:
                index = int(self.replace_string(var.index))
                name = "@{%s}" % var.get_replaced_base(self)
                return self[name][index]
            except (ValueError, DataError, IndexError):
                raise DataError("Non-existing variable '@{%s}[%s]'" % (var.base, var.index))
Exemplo n.º 9
0
 def _deprecate_escaped_cells_before_continuation(self, data):
     index = data.index(self._row_continuation_marker)
     if any(cell == '\\' for cell in data[:index]):
         LOGGER.warn("Error in file '%s': Escaping empty cells with "
                     "'\\' before line continuation marker '...' is "
                     "deprecated. Remove escaping before Robot "
                     "Framework 3.2." % self.source)
Exemplo n.º 10
0
def _get_multisource_suite(sources, include_suites, warn_on_skipped, process_variables):
    data = []
    for src in sources:
        try:
            data.append(_parse_suite(src, include_suites, warn_on_skipped))
        except DataError, err:
            LOGGER.warn(err)
Exemplo n.º 11
0
 def _log_imported_library(self, name, args, lib):
     type = lib.__class__.__name__.replace('Library', '').lower()[1:]
     LOGGER.info("Imported library '%s' with arguments %s "
                 "(version %s, %s type, %s scope, %d keywords)"
                 % (name, utils.seq2str2(args), lib.version,
                    type, lib.scope.lower(), len(lib)))
     if not lib:
         LOGGER.warn("Imported library '%s' contains no keywords" % name)
Exemplo n.º 12
0
 def _warn_about_registeration_error(self, signum, err):
     name, ctrlc = {
         signal.SIGINT: ('INT', 'or with Ctrl-C '),
         signal.SIGTERM: ('TERM', '')
     }[signum]
     LOGGER.warn('Registering signal %s failed. Stopping execution '
                 'gracefully with this signal %sis not possible. '
                 'Original error was: %s' % (name, ctrlc, err))
Exemplo n.º 13
0
 def _log_imported_library(self, name, args, lib):
     type = lib.__class__.__name__.replace('Library', '').lower()[1:]
     LOGGER.info("Imported library '%s' with arguments %s "
                 "(version %s, %s type, %s scope, %d keywords)"
                 % (name, utils.seq2str2(args), lib.version or '<unknown>',
                    type, lib.scope.lower(), len(lib)))
     if not lib:
         LOGGER.warn("Imported library '%s' contains no keywords" % name)
Exemplo n.º 14
0
 def _log_warning_when_basename_already_used(self, name, other, path):
     msg = ("Using same base name with scalar and list variables is "
            "deprecated. Please change either '%s' or '%s'") % (name, other)
     if path:
         msg += " in file '%s'" % path
     msg += " before Robot Framework 2.6."
     # If path is not known we are executing keywords and can log message
     LOGGER.warn(msg, log=not path)
Exemplo n.º 15
0
 def _deprecate_quoting(self, cell, path, line_number):
     if len(cell) > 1 and cell[0] == cell[-1] == '"':
         LOGGER.warn("TSV file '%s' has quotes around cells which is "
                     "deprecated and must be fixed. Remove quotes "
                     "from '%s' on line %d."
                     % (path, cell, line_number))
         return cell[1:-1].replace('""', '"').strip()
     return cell
Exemplo n.º 16
0
def _get_multisource_suite(sources, include_suites, warn_on_skipped,
                           process_variables):
    data = []
    for src in sources:
        try:
            data.append(_parse_suite(src, include_suites, warn_on_skipped))
        except DataError, err:
            LOGGER.warn(err)
Exemplo n.º 17
0
 def _convert_to_new_style_metadata(self):
     # TODO: Remove support for olde style metadata in RF 2.10.
     LOGGER.warn(
         "Setting suite metadata using '%s' syntax is deprecated. "
         "Use 'Metadata' setting with name and value in separate "
         "cells instead." % self.head
     )
     return ["Metadata"] + [self.head.split(":", 1)[1].strip()] + self.tail
Exemplo n.º 18
0
def build_resource(data, source):
    resource = ResourceFile(source=source)
    if data.sections:
        ResourceBuilder(resource).visit(data)
        LOGGER.info("Imported resource file '%s' (%d keywords)." %
                    (source, len(resource.keywords)))
    else:
        LOGGER.warn("Imported resource file '%s' is empty." % source)
    return resource
Exemplo n.º 19
0
def deprecate_tags_starting_with_hyphen(node, source):
    for tag in node.values:
        if tag.startswith('-'):
            LOGGER.warn(
                f"Error in file '{source}' on line {node.lineno}: "
                f"Settings tags starting with a hyphen using the '[Tags]' setting "
                f"is deprecated. In Robot Framework 5.2 this syntax will be used "
                f"for removing tags. Escape '{tag}' like '\\{tag}' to use the "
                f"literal value and to avoid this warning.")
Exemplo n.º 20
0
 def _log_imported_library(self, name, args, lib):
     type = lib.__class__.__name__.replace('Library', '').lower()[1:]
     listener = ', with listener' if lib.has_listener else ''
     LOGGER.info("Imported library '%s' with arguments %s "
                 "(version %s, %s type, %s scope, %d keywords%s)" %
                 (name, seq2str2(args), lib.version or '<unknown>', type,
                  lib.scope.lower(), len(lib), listener))
     if not lib and not lib.has_listener:
         LOGGER.warn("Imported library '%s' contains no keywords" % name)
Exemplo n.º 21
0
 def _process_cell(self, cell, path):
     if len(cell) > 1 and cell[0] == cell[-1] == '"':
         cell = cell[1:-1].replace('""', '"')
         if path not in self._warned_escaping:
             LOGGER.warn("Un-escaping quotes in TSV files is deprecated. "
                         "Change cells in '%s' to not contain surrounding "
                         "quotes." % path)
             self._warned_escaping.add(path)
     return cell
Exemplo n.º 22
0
 def build(self, source):
     LOGGER.info("Parsing resource file '%s'." % source)
     resource = self._parse(source)
     if resource.imports or resource.variables or resource.keywords:
         LOGGER.info("Imported resource file '%s' (%d keywords)." %
                     (source, len(resource.keywords)))
     else:
         LOGGER.warn("Imported resource file '%s' is empty." % source)
     return resource
Exemplo n.º 23
0
 def _log_imported_library(self, name, args, lib):
     type = lib.__class__.__name__.replace('Library', '').lower()[1:]
     listener = ', with listener' if lib.has_listener else ''
     LOGGER.info("Imported library '%s' with arguments %s "
                 "(version %s, %s type, %s scope, %d keywords%s)"
                 % (name, seq2str2(args), lib.version or '<unknown>',
                    type, lib.scope.lower(), len(lib), listener))
     if not lib and not lib.has_listener:
         LOGGER.warn("Imported library '%s' contains no keywords" % name)
Exemplo n.º 24
0
 def _process_cell(self, cell, path):
     if len(cell) > 1 and cell[0] == cell[-1] == '"':
         cell = cell[1:-1].replace('""', '"')
         if path not in self._warned_escaping:
             LOGGER.warn("Un-escaping quotes in TSV files is deprecated. "
                         "Change cells in '%s' to not contain surrounding "
                         "quotes." % path)
             self._warned_escaping.add(path)
     return cell
Exemplo n.º 25
0
 def _process_deprecated_cli_opts(self, opts):
     for oldname, newname in self._deprecated.items():
         if oldname not in opts or opts[oldname] in [None, []]:
             continue
         if newname:
             LOGGER.warn("Option '--%s' is deprecated. Use '--%s' instead."
                         % (oldname, newname))
             opts[newname] = opts[oldname]
         else:
             LOGGER.error("Option '--%s' has been removed." % oldname)
Exemplo n.º 26
0
 def _run_tests(self, context, errors):
     executed_tests = []
     for test in self.tests:
         normname = utils.normalize(test.name)
         if normname in executed_tests:
             LOGGER.warn("Multiple test cases with name '%s' executed in "
                         "test suite '%s'" % (test.name, self.longname))
         executed_tests.append(normname)
         test.run(context, errors)
         context.set_prev_test_variables(test)
Exemplo n.º 27
0
 def _run_tests(self, context, errors):
     executed_tests = []
     for test in self.tests:
         normname = utils.normalize(test.name)
         if normname in executed_tests:
             LOGGER.warn("Multiple test cases with name '%s' executed in "
                         "test suite '%s'"% (test.name, self.longname))
         executed_tests.append(normname)
         test.run(context, errors)
         context.set_prev_test_variables(test)
Exemplo n.º 28
0
 def _process_deprecated_cli_opts(self, opts):
     for oldname, newname in self._deprecated.items():
         if oldname not in opts or opts[oldname] in [None, []]:
             continue
         if newname:
             LOGGER.warn(
                 "Option '--%s' is deprecated. Use '--%s' instead." %
                 (oldname, newname))
             opts[newname] = opts[oldname]
         else:
             LOGGER.error("Option '--%s' has been removed." % oldname)
Exemplo n.º 29
0
 def _get_var_table_scalar_value(self, name, value, path=None):
     if len(value) == 1:
         return self.replace_scalar(value[0])
     msg = ("Creating a scalar variable with a list value in the Variable "
            "table is deprecated and this functionality will be removed in "
            "Robot Framework 2.8. Create a list variable '@%s' and use "
            "it as a scalar variable '%s' instead" % (name[1:], name))
     if path:
         msg += " in file '%s'" % path
     LOGGER.warn(msg + '.')
     return self.replace_list(value)
Exemplo n.º 30
0
 def _check_deprecations(self, cells, path, line_number):
     for original in cells:
         normalized = ' '.join(original.split())
         if normalized != original:
             if len(normalized) != len(original):
                 msg = 'Collapsing consecutive whitespace'
             else:
                 msg = 'Converting whitespace characters to ASCII spaces'
             LOGGER.warn("%s during parsing is deprecated. Fix %s in file "
                         "'%s' on line %d." %
                         (msg, prepr(original), path, line_number))
         yield normalized
Exemplo n.º 31
0
 def main(self, datasources, **options):
     settings = RebotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     if settings['XUnitSkipNonCritical']:
         LOGGER.warn(
             "Command line option --xunitskipnoncritical has been deprecated."
         )
     LOGGER.disable_message_cache()
     rc = ResultWriter(*datasources).write_results(settings)
     if rc < 0:
         raise DataError('No outputs created.')
     return rc
Exemplo n.º 32
0
 def _check_deprecations(self, cells, path, line_number):
     for original in cells:
         normalized = self._normalize_whitespace(original)
         if normalized != original:
             if len(normalized) != len(original):
                 msg = 'Collapsing consecutive whitespace'
             else:
                 msg = 'Converting whitespace characters to ASCII spaces'
             LOGGER.warn("%s during parsing is deprecated. Fix %s in file "
                         "'%s' on line %d."
                         % (msg, prepr(original), path, line_number))
         yield normalized
Exemplo n.º 33
0
 def _validate_arguments_exist(self, arguments):
     valid = []
     nonex = []
     for arg in arguments:
         (valid if os.path.exists(arg) else nonex).append(arg)
     if nonex:
         s, were = ('s', 'were') if len(nonex) > 1 else ('', 'was')
         LOGGER.warn("Argument%s %s did not exist and %s ignored. "
                     "Validate the used command line syntax."
                     % (s, seq2str(nonex), were))
         if not valid:
             raise DataError('No valid arguments given.')
     return valid
 def _removed_in_26(self, name, log):
     start, instead = {
         'SplitOutputs': ('Splitting outputs is',
                          'The --splitlog option can be used instead. '),
         'Summary':      ('Summary reports are', ''),
         'SummaryTitle': ('Summary titles are', '')
     }[name]
     option, default = self._cli_opts[name]
     if log:
         LOGGER.warn('%s not supported in Robot Framework 2.6 or newer. %s'
                     'The --%s option will be removed altogether in '
                     'version 2.7.' % (start, instead, option))
     return default
Exemplo n.º 35
0
 def _validate_arguments_exist(self, arguments):
     valid = []
     nonex = []
     for arg in arguments:
         (valid if os.path.exists(arg) else nonex).append(arg)
     if nonex:
         s, were = ('s', 'were') if len(nonex) > 1 else ('', 'was')
         LOGGER.warn("Argument%s %s did not exist and %s ignored. "
                     "Validate the used command line syntax." %
                     (s, seq2str(nonex), were))
         if not valid:
             raise DataError('No valid arguments given.')
     return valid
Exemplo n.º 36
0
def build_resource(data, source):
    resource = ResourceFile(source=source)
    if data.data_sections:
        ErrorLogger(source).visit(data)
        if data.has_tests:
            raise DataError("Resource file '%s' cannot contain tests or tasks." %
                            source)
        ResourceBuilder(resource).visit(data)
        LOGGER.info("Imported resource file '%s' (%d keywords)."
                    % (source, len(resource.keywords)))
    else:
        LOGGER.warn("Imported resource file '%s' is empty." % source)
    return resource
Exemplo n.º 37
0
 def _check_deprecated_extensions(self, source):
     if os.path.isdir(source):
         return
     ext = os.path.splitext(source)[1][1:].lower()
     if self.extensions and ext in self.extensions:
         return
     # HTML files cause deprecation warning that cannot be avoided with
     # --extension at parsing time. No need for double warning.
     if ext not in ('robot', 'html', 'htm', 'xhtml'):
         LOGGER.warn("Automatically parsing other than '*.robot' files is "
                     "deprecated. Convert '%s' to '*.robot' format or use "
                     "'--extension' to explicitly configure which files to "
                     "parse." % source)
 def _unescape_opts_and_args(self, opts, args):
     from robot.output import LOGGER
     with LOGGER.cache_only:
         LOGGER.warn("Option '--escape' is deprecated. Use console escape "
                     "mechanism instead.")
     try:
         escape_strings = opts['escape']
     except KeyError:
         raise FrameworkError("No 'escape' in options")
     escapes = self._get_escapes(escape_strings)
     for name, value in opts.items():
         if name != 'escape':
             opts[name] = self._unescape(value, escapes)
     return opts, [self._unescape(arg, escapes) for arg in args]
 def _unescape_opts_and_args(self, opts, args):
     from robot.output import LOGGER
     with LOGGER.cache_only:
         LOGGER.warn("Option '--escape' is deprecated. Use console escape "
                     "mechanism instead.")
     try:
         escape_strings = opts['escape']
     except KeyError:
         raise FrameworkError("No 'escape' in options")
     escapes = self._get_escapes(escape_strings)
     for name, value in opts.items():
         if name != 'escape':
             opts[name] = self._unescape(value, escapes)
     return opts, [self._unescape(arg, escapes) for arg in args]
Exemplo n.º 40
0
 def _process_value(self, name, value):
     if name in ['ReRunFailed', 'DeprecatedRunFailed']:
         return gather_failed_tests(value)
     if name == 'LogLevel':
         return self._process_log_level(value)
     if value == self._get_default_value(name):
         return value
     if name in ['Name', 'Doc', 'LogTitle', 'ReportTitle']:
         if name == 'Doc':
             value = self._escape_as_data(value)
         return value.replace('_', ' ')
     if name in ['Metadata', 'TagDoc']:
         if name == 'Metadata':
             value = [self._escape_as_data(v) for v in value]
         return [self._process_metadata_or_tagdoc(v) for v in value]
     if name in ['Include', 'Exclude']:
         return [self._format_tag_patterns(v) for v in value]
     if name in self._output_opts and (not value
                                       or value.upper() == 'NONE'):
         return None
     if name == 'DeprecatedXUnit':
         LOGGER.warn(
             'Option --xunitfile is deprecated. Use --xunit instead.')
         return self._process_value('XUnit', value)
     if name == 'OutputDir':
         return utils.abspath(value)
     if name in ['SuiteStatLevel', 'MonitorWidth']:
         return self._convert_to_positive_integer_or_default(name, value)
     if name in ['Listeners', 'VariableFiles']:
         return [self._split_args_from_name_or_path(item) for item in value]
     if name == 'ReportBackground':
         return self._process_report_background(value)
     if name == 'TagStatCombine':
         return [self._process_tag_stat_combine(v) for v in value]
     if name == 'TagStatLink':
         return [
             v for v in [self._process_tag_stat_link(v) for v in value] if v
         ]
     if name == 'Randomize':
         return self._process_randomize_value(value)
     if name == 'RunMode':
         LOGGER.warn(
             'Option --runmode is deprecated in Robot Framework 2.8 '
             'and will be removed in the future.')
         return [self._process_runmode_value(v) for v in value]
     if name == 'RemoveKeywords':
         self._validate_remove_keywords(value)
     if name == 'FlattenKeywords':
         self._validate_flatten_keywords(value)
     return value
Exemplo n.º 41
0
 def read(self, htmlfile, populator, path=None):
     self.populator = populator
     self.state = self.IGNORE
     self.current_row = None
     self.current_cell = None
     for line in htmlfile.readlines():
         self.feed(self._decode(line))
     # Calling close is required by the HTMLParser but may cause problems
     # if the same instance of our HtmlParser is reused. Currently it's
     # used only once so there's no problem.
     self.close()
     if self.populator.eof():
         LOGGER.warn("Using test data in HTML format is deprecated. "
                     "Convert '%s' to plain text format."
                     % (path or htmlfile.name))
Exemplo n.º 42
0
 def read(self, htmlfile, populator, path=None):
     self.populator = populator
     self.state = self.IGNORE
     self.current_row = None
     self.current_cell = None
     for line in htmlfile.readlines():
         self.feed(self._decode(line))
     # Calling close is required by the HTMLParser but may cause problems
     # if the same instance of our HtmlParser is reused. Currently it's
     # used only once so there's no problem.
     self.close()
     if self.populator.eof():
         LOGGER.warn("Using test data in HTML format is deprecated. "
                     "Convert '%s' to plain text format." %
                     (path or htmlfile.name))
Exemplo n.º 43
0
 def main(self, datasources, **options):
     settings = RebotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     if settings['Critical'] or settings['NonCritical']:
         LOGGER.warn("Command line options --critical and --noncritical have been "
                     "deprecated and have no effect with Rebot. Use --skiponfailure "
                     "when starting execution instead.")
     if settings['XUnitSkipNonCritical']:
         LOGGER.warn("Command line option --xunitskipnoncritical has been "
                     "deprecated and has no effect.")
     LOGGER.disable_message_cache()
     rc = ResultWriter(*datasources).write_results(settings)
     if rc < 0:
         raise DataError('No outputs created.')
     return rc
Exemplo n.º 44
0
 def _process_value(self, name, value):
     if name == 'ReRunFailed':
         return gather_failed_tests(value)
     if name == 'ReRunFailedSuites':
         return gather_failed_suites(value)
     if name == 'LogLevel':
         return self._process_log_level(value)
     if value == self._get_default_value(name):
         return value
     if name == 'Doc':
         return self._escape_as_data(value)
     if name in ['Metadata', 'TagDoc']:
         if name == 'Metadata':
             value = [self._escape_as_data(v) for v in value]
         return [self._process_metadata_or_tagdoc(v) for v in value]
     if name in ['Include', 'Exclude']:
         return [self._format_tag_patterns(v) for v in value]
     if name in self._output_opts and (not value
                                       or value.upper() == 'NONE'):
         return None
     if name == 'OutputDir':
         return abspath(value)
     if name in ['SuiteStatLevel', 'ConsoleWidth']:
         return self._convert_to_positive_integer_or_default(name, value)
     if name == 'VariableFiles':
         return [split_args_from_name_or_path(item) for item in value]
     if name == 'ReportBackground':
         return self._process_report_background(value)
     if name == 'TagStatCombine':
         return [self._process_tag_stat_combine(v) for v in value]
     if name == 'TagStatLink':
         return [
             v for v in [self._process_tag_stat_link(v) for v in value] if v
         ]
     if name == 'Randomize':
         return self._process_randomize_value(value)
     if name == 'MaxErrorLines':
         return self._process_max_error_lines(value)
     if name == 'RemoveKeywords':
         self._validate_remove_keywords(value)
     if name == 'FlattenKeywords':
         self._validate_flatten_keywords(value)
     if name == 'WarnOnSkipped':
         with LOGGER.cache_only:
             LOGGER.warn("Option '--warnonskippedfiles' is deprecated and "
                         "has no effect. Nowadays all skipped files are "
                         "reported.")
     return value
Exemplo n.º 45
0
 def _import_library(self, name, positional, named, lib):
     key = (name, positional, named)
     if self._libraries.has_key(key):
         LOGGER.info("Found test library '%s' with arguments %s from cache"
                     % (name, utils.seq2str2(positional)))
         return self._libraries[key]
     lib.create_handlers()
     self._libraries[key] = lib
     libtype = lib.__class__.__name__.replace('Library', '').lower()[1:]
     LOGGER.info("Imported library '%s' with arguments %s (version %s, "
                 "%s type, %s scope, %d keywords, source %s)"
                 % (name, utils.seq2str2(positional), lib.version, libtype,
                    lib.scope.lower(), len(lib), lib.source))
     if len(lib) == 0:
         LOGGER.warn("Imported library '%s' contains no keywords" % name)
     return lib
 def _process_value(self, name, value):
     if name == 'ReRunFailed':
         return gather_failed_tests(value)
     if name == 'DeprecatedRunFailed':
         if value.upper() != 'NONE':
             LOGGER.warn('Option --runfailed is deprecated and will be '
                         'removed in the future. Use --rerunfailed instead.')
         return gather_failed_tests(value)
     if name == 'DeprecatedMerge' and value is True:
         LOGGER.warn('Option --rerunmerge is deprecated and will be '
                     'removed in the future. Use --merge instead.')
     if name == 'LogLevel':
         return self._process_log_level(value)
     if value == self._get_default_value(name):
         return value
     if name in ['Name', 'Doc', 'LogTitle', 'ReportTitle']:
         if name == 'Doc':
             value = self._escape_as_data(value)
         return value.replace('_', ' ')
     if name in ['Metadata', 'TagDoc']:
         if name == 'Metadata':
             value = [self._escape_as_data(v) for v in value]
         return [self._process_metadata_or_tagdoc(v) for v in value]
     if name in ['Include', 'Exclude']:
         return [self._format_tag_patterns(v) for v in value]
     if name in self._output_opts and (not value or value.upper() == 'NONE'):
         return None
     if name == 'OutputDir':
         return utils.abspath(value)
     if name in ['SuiteStatLevel', 'MonitorWidth']:
         return self._convert_to_positive_integer_or_default(name, value)
     if name in ['PreRunModifiers', 'PreRebotModifiers', 'Listeners',
                 'VariableFiles']:
         return [self._split_args_from_name_or_path(item) for item in value]
     if name == 'ReportBackground':
         return self._process_report_background(value)
     if name == 'TagStatCombine':
         return [self._process_tag_stat_combine(v) for v in value]
     if name == 'TagStatLink':
         return [v for v in [self._process_tag_stat_link(v) for v in value] if v]
     if name == 'Randomize':
         return self._process_randomize_value(value)
     if name == 'RemoveKeywords':
         self._validate_remove_keywords(value)
     if name == 'FlattenKeywords':
         self._validate_flatten_keywords(value)
     return value
Exemplo n.º 47
0
 def _filter_stdlib_handler(self, handler1, handler2):
     if handler1.library.orig_name in STDLIB_NAMES:
         standard, external = handler1, handler2
     elif handler2.library.orig_name in STDLIB_NAMES:
         standard, external = handler2, handler1
     else:
         return [handler1, handler2]
     if not RUN_KW_REGISTER.is_run_keyword(external.library.orig_name, external.name):
         LOGGER.warn(
             "Keyword '%s' found both from a user created test library "
             "'%s' and Robot Framework standard library '%s'. The user "
             "created keyword is used. To select explicitly, and to get "
             "rid of this warning, use either '%s' or '%s'."
             % (standard.name,
                external.library.orig_name, standard.library.orig_name,
                external.longname, standard.longname))
     return [external]
Exemplo n.º 48
0
 def _import_library(self, name, positional, named, lib):
     key = (name, positional, named)
     if self._libraries.has_key(key):
         LOGGER.info(
             "Found test library '%s' with arguments %s from cache" %
             (name, utils.seq2str2(positional)))
         return self._libraries[key]
     lib.create_handlers()
     self._libraries[key] = lib
     libtype = lib.__class__.__name__.replace('Library', '').lower()[1:]
     LOGGER.info("Imported library '%s' with arguments %s (version %s, "
                 "%s type, %s scope, %d keywords, source %s)" %
                 (name, utils.seq2str2(positional), lib.version, libtype,
                  lib.scope.lower(), len(lib), lib.source))
     if len(lib) == 0:
         LOGGER.warn("Imported library '%s' contains no keywords" % name)
     return lib
Exemplo n.º 49
0
 def _filter_stdlib_handler(self, handler1, handler2):
     if handler1.library.orig_name in STDLIB_NAMES:
         standard, external = handler1, handler2
     elif handler2.library.orig_name in STDLIB_NAMES:
         standard, external = handler2, handler1
     else:
         return [handler1, handler2]
     if not RUN_KW_REGISTER.is_run_keyword(external.library.orig_name, external.name):
         LOGGER.warn(
             "Keyword '%s' found both from a user created test library "
             "'%s' and Robot Framework standard library '%s'. The user "
             "created keyword is used. To select explicitly, and to get "
             "rid of this warning, use either '%s' or '%s'."
             % (standard.name,
                external.library.orig_name, standard.library.orig_name,
                external.longname, standard.longname))
     return [external]
Exemplo n.º 50
0
 def _process_value(self,name,value):
     if name =='RunFailed':
         return gather_failed_tests(value)
     if name =='LogLevel':
         return self._process_log_level(value)
     if value == self._get_default_value(name):
         return value
     if name in ['Name','Doc','LogTitle','ReportTitle']:
         if name =='Doc':
             value= self._escape_as_data(value)
         return value.replace('_',' ')
     if name in  ['Metadata','TagDoc']:
         if name == 'Metadata':
             value = [self._escape_as_data(v) for v in value]
         return [self._process_metadata_or_tagdoc(v)  for v in value]
     if name in ['Include','Exclude']:
         return [v.replace('AND','&').replace('_','') for in value]
     if name in self._output_opts and (not value or value.upper()=='NONE'):
         return None
     if name =='DeprecatedXUnit':
         LOGGER.warn('Option --xunitfile is deprecated use --xunit instead')
         return self._process_value('XUnit',value)
     if name =='OutputDir':
         return utils.abspath(value)
     if name in ['SuiteStatLevel','MonitorWidth']:
         return self._convert_to_positive_integer_or_default(name,value)
     if name in ['Listeners','VariableFiles']:
         return [self._split_args_from_name_or_path(item) for item in value]
     if name =='ReportBackground':
         return self._process_report_background(value)
     if name =='TagStatCombine':
         return [self._process_tag_stat_combine(v) for v in value]
     if name =='TagStatLink':
         return [v for v in [self._process_tag_stat_link(v) for v in value ] if v]
     if name =='Randomize':
         return self._process_randomize_value(value)
     if name =='RemoveKeywords':
         return [v.upper() for v in value]
     if name =='RunMode':
         LOGGER.warn('Option --runmode is deprecated in robot Framework 2.8'
                     'and will be removed in the future'
                     )
         return [self._process_runmode_value(v) for v in value]
     return value
Exemplo n.º 51
0
 def set_runmode(self, runmode):
     origmode = runmode
     runmode = runmode.upper()
     if runmode == 'EXITONFAILURE':
         self._run_mode_exit_on_failure = True
     elif runmode == 'SKIPTEARDOWNONEXIT':
         self._run_mode_skip_teardowns_on_exit = True
     elif runmode == 'DRYRUN':
         self._run_mode_dry_run = True
     elif runmode == 'RANDOM:TEST':
         random.shuffle(self.tests)
     elif runmode == 'RANDOM:SUITE':
         random.shuffle(self.suites)
     elif runmode == 'RANDOM:ALL':
         random.shuffle(self.suites)
         random.shuffle(self.tests)
     else:
         from robot.output import LOGGER  # avoid recursive import
         LOGGER.warn("Option '--runmode' does not support value '%s'." % origmode)
         return
     for suite in self.suites:
         suite.set_runmode(runmode)
Exemplo n.º 52
0
    def _get_variable(self, var):
        """'var' is an instance of a VariableSplitter"""
        # 1) Handle reserved syntax
        if var.identifier not in '$@%':
            value = '%s{%s}' % (var.identifier, var.base)
            LOGGER.warn("Syntax '%s' is reserved for future use. Please "
                        "escape it like '\\%s'." % (value, value))
            return value

        # 2) Handle environment variables and Java system properties
        elif var.identifier == '%':
            name = var.get_replaced_base(self).strip()
            if not name:
                return '%%{%s}' % var.base
            value = utils.get_env_var(name)
            if value is not None:
                return value
            value = getJavaSystemProperty(name)
            if value is not None:
                return value
            msg = "Environment variable '%%{%s}' not found." % name
            self._raise_non_existing_variable('%%{%s}' % name, msg,
                                              env_vars=True)

        # 3) Handle ${scalar} variables and @{list} variables without index
        elif var.index is None:
            name = '%s{%s}' % (var.identifier, var.get_replaced_base(self))
            return self[name]

        # 4) Handle items from list variables e.g. @{var}[1]
        else:
            try:
                index = int(self.replace_string(var.index))
                name = '@{%s}' % var.get_replaced_base(self)
                return self[name][index]
            except (ValueError, DataError, IndexError):
                msg = ("Variable '@{%s}[%s]' not found."
                       % (var.base, var.index))
                self._raise_non_existing_variable(var.base, msg)
Exemplo n.º 53
0
 def _get_reserved_variable(self, splitter):
     value = splitter.get_replaced_variable(self)
     LOGGER.warn("Syntax '%s' is reserved for future use. Please " "escape it like '\\%s'." % (value, value))
     return value
Exemplo n.º 54
0
 def _log_failed_parsing(self, message, warn):
     if warn:
         LOGGER.warn(message)
     else:
         LOGGER.info(message)
Exemplo n.º 55
0
 def _report_status(self):
     if self.setting_table or self.variable_table or self.keyword_table:
         LOGGER.info("Imported resource file '%s' (%d keywords)."
                     % (self.source, len(self.keyword_table.keywords)))
     else:
         LOGGER.warn("Imported resource file '%s' is empty." % self.source)
Exemplo n.º 56
0
 def _deprecate_empty_data_cells(self, cells, path, line_number):
     data_cells = dropwhile(lambda c: not c, cells)
     if not all(data_cells):
         LOGGER.warn("TSV file '%s' has empty data cells which is "
                     "deprecated and must be fixed. Escape empty cells "
                     "on line %d with '${EMPTY}'." % (path, line_number))