Skip to content

Commit

Permalink
runner: use test/task correctly in messages
Browse files Browse the repository at this point in the history
  • Loading branch information
yanne committed Oct 1, 2020
1 parent bec3a19 commit 08ba690
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dist
target
venv*
.venv*
.env
*~
MANIFEST
atest/results
Expand Down
11 changes: 11 additions & 0 deletions atest/robot/running/skip_in_rpa_mode.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*** Settings ***
Suite Setup Run Tests --rpa --skip skip-this --SkipOnFailure skip-on-failure --variable test_or_task:Task running/skip/
Resource atest_resource.robot

*** Test Cases ***
Skipped with --skip
Check Test Case ${TEST NAME}

Skipped with --SkipOnFailure
Check Test Case ${TEST NAME}

9 changes: 6 additions & 3 deletions atest/testdata/running/skip/skip.robot
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
*** Settings ***
Library skiplib.py

*** Variables ***
${TEST_OR_TASK} Test

*** Test Cases ***
Skip Keyword
[Documentation] SKIP Skipped with Skip keyword.
Expand Down Expand Up @@ -32,17 +35,17 @@ Skipped in Setup 2

Skipped with --skip
[Tags] skip-this
[Documentation] SKIP Test skipped with --skip command line option.
[Documentation] SKIP ${TEST_OR_TASK} skipped with --skip command line option.
Fail

Skipped with --SkipOnFailure
[Tags] skip-on-failure
[Documentation] SKIP Test skipped with --SkipOnFailure, original error:\nAssertionError
[Documentation] SKIP ${TEST_OR_TASK} skipped with --SkipOnFailure, original error:\nAssertionError
Fail

--NonCritical Is an Alias for --SkipOnFailure
[Tags] non-crit
[Documentation] SKIP Test skipped with --SkipOnFailure, original error:\nAssertionError
[Documentation] SKIP ${TEST_OR_TASK} skipped with --SkipOnFailure, original error:\nAssertionError
Fail

--Critical can be used to override --SkipOnFailure
Expand Down
20 changes: 14 additions & 6 deletions src/robot/running/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from robot.errors import ExecutionStatus, DataError, PassExecution
from robot.model import SuiteVisitor, TagPatterns
from robot.result import TestSuite, Result
from robot.utils import get_timestamp, is_list_like, NormalizedDict, unic
from robot.utils import (get_timestamp, is_list_like, NormalizedDict, unic,
test_or_task)
from robot.variables import VariableScopes

from .context import EXECUTION_CONTEXTS
Expand Down Expand Up @@ -119,17 +120,24 @@ def visit_test(self, test):
self._output.start_test(ModelCombiner(test, result))
status = TestStatus(self._suite_status, result,
self._settings.skip_on_failure,
self._settings.critical_tags)
self._settings.critical_tags,
self._settings.rpa)
if status.exit:
self._add_exit_combine()
result.tags.add('robot:exit')
# TODO: helper for resolving test/tags
if self._skipped_tags.match(test.tags):
status.test_skipped("Test skipped with --skip command line option.")
status.test_skipped(
test_or_task(
"{Test} skipped with --skip command line option.",
self._settings.rpa))
if not status.failed and not test.name:
status.test_failed('Test case name cannot be empty.')
status.test_failed(
test_or_task('{Test} case name cannot be empty.',
self._settings.rpa))
if not status.failed and not test.keywords.normal:
status.test_failed('Test case contains no keywords.')
status.test_failed(
test_or_task('{Test} case contains no keywords.',
self._settings.rpa))
self._run_setup(test.keywords.setup, status, result)
try:
if not status.failed:
Expand Down
12 changes: 7 additions & 5 deletions src/robot/running/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from robot.errors import ExecutionFailed, PassExecution
from robot.model.tags import TagPatterns
from robot.utils import html_escape, py2to3, unic
from robot.utils import html_escape, py2to3, unic, test_or_task


@py2to3
Expand Down Expand Up @@ -138,17 +138,19 @@ def _my_message(self):

class TestStatus(_ExecutionStatus):

def __init__(self, parent, test, skip_on_failure=None, critical_tags=None):
def __init__(self, parent, test, skip_on_failure=None, critical_tags=None,
rpa=False):
_ExecutionStatus.__init__(self, parent)
self.exit = parent.exit
self._skip_on_failure = self._should_skip_on_failure(
test, skip_on_failure, critical_tags)
self._rpa = rpa

def test_failed(self, failure):
if self._skip_on_failure:
self.failure.test = \
("Test skipped with --SkipOnFailure, original error:\n%s"
% unic(failure))
msg = ("%s skipped with --SkipOnFailure, original error:\n%s"
% (test_or_task('{Test}', self._rpa) ,unic(failure)))
self.failure.test = msg
self.skipped = True
else:
self.failure.test = unic(failure)
Expand Down

0 comments on commit 08ba690

Please sign in to comment.