Revision: 4362
Author: jussi.ao.malinen
Date: Fri Dec 3 01:42:43 2010
Log: don't import anything when execution has been stopped (issue 723)
http://code.google.com/p/robotframework/source/detail?r=4362
Modified:
/trunk/atest/resources/atest_resource.txt
/trunk/atest/robot/cli/runner/exit_on_failure.txt
/trunk/atest/robot/running/fatal_exception.txt
/trunk/atest/testdata/running/fatal_exception/02__irrelevant.txt
/trunk/src/robot/running/model.py
/trunk/src/robot/running/namespace.py
/trunk/src/robot/running/runerrors.py
=======================================
--- /trunk/atest/resources/atest_resource.txt Thu Aug 26 03:46:00 2010
+++ /trunk/atest/resources/atest_resource.txt Fri Dec 3 01:42:43 2010
@@ -268,3 +268,7 @@
Log ${time}
Should Be True isinstance(${time}, int) and ${time} >= 0 Not valid
elapsed time
+Previous test should have passed
+ [Arguments] ${name}
+ Should be equal ${PREV TEST NAME} ${name}
+ Should be equal ${PREV TEST STATUS} PASS
=======================================
--- /trunk/atest/robot/cli/runner/exit_on_failure.txt Tue Aug 24 03:15:42
2010
+++ /trunk/atest/robot/cli/runner/exit_on_failure.txt Fri Dec 3 01:42:43
2010
@@ -4,11 +4,15 @@
*** Test Cases ***
Exit On Failure
- [Setup] Run Tests --runmode exitonfailure misc/pass_and_fail.html
misc/suites
+ [Setup] Run Tests --runmode exitonfailure misc/pass_and_fail.html
misc/suites running/fatal_exception/02__irrelevant.txt
Check Test Case Pass
Check Test Case Fail
Check Test Case SubSuite1 First FAIL Critical failure occurred and
ExitOnFailure option is in use
Check Test Case Suite3 First FAIL Critical failure occurred and
ExitOnFailure option is in use
+
+Imports Are Skipped On Exit
+ Previous test should have passed Exit On Failure
+ Should be empty ${ERRORS.messages}
Correct Suite Teardown Is Executed When Exitonfailure Is Used
[Setup] Run Tests --runmode exitonfailure misc/suites
=======================================
--- /trunk/atest/robot/running/fatal_exception.txt Tue Aug 24 03:23:39 2010
+++ /trunk/atest/robot/running/fatal_exception.txt Fri Dec 3 01:42:43 2010
@@ -22,6 +22,10 @@
Check Test Case Test That Should Not Be Run 1
Check Test Case Test That Should Not Be Run 2.1
Check Test Case Test That Should Not Be Run 2.2
+
+Skip Imports On Exit
+ Previous test should have passed Multiple Suite Aware Exiting
+ Should be empty ${ERRORS.messages}
Fatal Exception and Runmode Exit on Failure
Run Tests --runmode exitonfailure
running/fatal_exception/01__python_library_kw.txt
=======================================
--- /trunk/atest/testdata/running/fatal_exception/02__irrelevant.txt Fri
Apr 23 04:39:45 2010
+++ /trunk/atest/testdata/running/fatal_exception/02__irrelevant.txt Fri
Dec 3 01:42:43 2010
@@ -1,3 +1,8 @@
+*** Settings ***
+Library NonExisting
+Resource NotEither.txt
+Variables NotHere.py
+
*** Test Cases ***
Test That Should Not Be Run 2.1
[Documentation] FAIL Test execution is stopped due to a fatal error
=======================================
--- /trunk/src/robot/running/model.py Wed Dec 1 08:10:46 2010
+++ /trunk/src/robot/running/model.py Fri Dec 3 01:42:43 2010
@@ -127,8 +127,8 @@
self.status = 'RUNNING'
self.starttime = utils.get_timestamp()
parent_vars = parent.context.get_current_vars() if parent else None
- self.context = ExecutionContext(Namespace(self, parent_vars),
output,
- self._run_mode_dry_run)
+ ns = Namespace(self, parent_vars, skip_imports=errors.exit)
+ self.context = ExecutionContext(ns, output, self._run_mode_dry_run)
self._set_variable_dependent_metadata(self.context)
output.start_suite(self)
return self.context
=======================================
--- /trunk/src/robot/running/namespace.py Thu Dec 2 03:59:36 2010
+++ /trunk/src/robot/running/namespace.py Fri Dec 3 01:42:43 2010
@@ -40,7 +40,7 @@
A new instance of this class is created for each test suite.
"""
- def __init__(self, suite, parent_vars):
+ def __init__(self, suite, parent_vars, skip_imports=False):
if suite is not None:
LOGGER.info("Initializing namespace for test suite '%s'" %
suite.longname)
self.variables = _VariableScopes(suite, parent_vars)
@@ -55,7 +55,7 @@
self.import_library('BuiltIn')
self.import_library('Reserved')
self.import_library('Easter')
- if suite.source is not None:
+ if suite.source and not skip_imports:
self._handle_imports(suite.imports)
robot.running.NAMESPACES.start_suite(self)
self.variables['${SUITE_NAME}'] = suite.longname
=======================================
--- /trunk/src/robot/running/runerrors.py Tue Aug 24 03:15:42 2010
+++ /trunk/src/robot/running/runerrors.py Fri Dec 3 01:42:43 2010
@@ -20,7 +20,6 @@
_parent_suite_init_error = 'Initialization of the parent suite failed.'
_parent_suite_setup_error = 'Setup of the parent suite failed.'
-
def __init__(self, run_mode_is_exit_on_failure=False,
run_mode_skip_teardowns_on_exit=False):
self._run_mode_is_exit_on_failure = run_mode_is_exit_on_failure
self._run_mode_skip_teardowns_on_exit =
run_mode_skip_teardowns_on_exit
@@ -31,6 +30,10 @@
self._exit_runmode = self._exit_fatal = False
self._current_suite_setup_executed = False
+ @property
+ def exit(self):
+ return self._exit_fatal or self._exit_runmode
+
def _init_current_errors(self):
self._current_init_err = self._current_setup_err = self._NO_ERROR