Revision: 3877
Author: jussi.ao.malinen
Date: Tue Aug 24 03:15:42 2010
Log: Skip Teardowns On Exit (still missing documentation and one test)
http://code.google.com/p/robotframework/source/detail?r=3877
Added:
/trunk/atest/robot/cli/runner/exit_on_failure.txt
/trunk/atest/robot/cli/runner/random_order.txt
Deleted:
/trunk/atest/robot/cli/runner/runmode.txt
Modified:
/trunk/atest/robot/running/stopping_with_signal.txt
/trunk/atest/testdata/misc/suites/fourth.html
/trunk/src/robot/common/model.py
/trunk/src/robot/conf/settings.py
/trunk/src/robot/runner.py
/trunk/src/robot/running/model.py
/trunk/src/robot/running/runerrors.py
=======================================
--- /dev/null
+++ /trunk/atest/robot/cli/runner/exit_on_failure.txt Tue Aug 24 03:15:42
2010
@@ -0,0 +1,29 @@
+*** Settings ***
+Force Tags pybot jybot regression
+Resource atest_resource.txt
+
+*** Test Cases ***
+Exit On Failure
+ [Setup] Run Tests --runmode exitonfailure misc/pass_and_fail.html
misc/suites
+ 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
+
+Correct Suite Teardown Is Executed When Exitonfailure Is Used
+ [Setup] Run Tests --runmode exitonfailure misc/suites
+ ${tsuite} = Get Test Suite Suites
+ Should Be Equal ${tsuite.teardown.name} BuiltIn.Log
+ ${tsuite} = Get Test Suite Fourth
+ Should Be Equal ${tsuite.teardown.name} BuiltIn.Log
+ ${tsuite} = Get Test Suite Tsuite3
+ Should Be Equal ${tsuite.teardown} ${None}
+
+Exit On Failure With Skip Teardown On Exit
+ [Setup] Run Tests --runmode ExitOnFailure --runmode
SkipTeardownOnExit misc/suites
+ ${tcase} = Check Test Case Suite4 First
+ Should Be Equal ${tcase.teardown} ${None}
+ ${tsuite} = Get Test Suite Fourth
+ Should Be Equal ${tsuite.teardown} ${None}
+ 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
=======================================
--- /dev/null
+++ /trunk/atest/robot/cli/runner/random_order.txt Tue Aug 24 03:15:42 2010
@@ -0,0 +1,37 @@
+*** Settings ***
+Suite Setup Check That Default Orders Are Correct
+Force Tags pybot jybot regression
+Resource atest_resource.txt
+
+*** Variables ***
+${DEFAULT SUITE ORDER} ['Suite
First', 'Subsuite1', 'Suite3', 'Suite4', 'Suite5', 'Suite10', 'Suite
6', 'SUite7', 'suiTe 8', 'Suite 9 Name']
+${DEFAULT TEST ORDER}
['test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7', 'test8', 'test9', 'test10', 'test11', 'test12']
+
+*** Test Cases ***
+Randomizing Tests
+ [Setup] Run Tests --runmode random:test
misc/multiple_suites/01__suite_first.html
+ Should Not Be Equal As Strings ${SUITE.tests} ${DEFAULT TEST ORDER}
+
+Randomizing Suites
+ [Setup] Run Tests --runmode RANDOM:SuitE misc/multiple_suites
+ Should Not Be Equal As Strings ${SUITE.suites} ${DEFAULT SUITE ORDER}
+ ${tests} = Get Tests
+ Should Be Equal As Strings ${tests} ${DEFAULT TEST ORDER}
+
+Randomizing Suites And Tests
+ [Setup] Run Tests --runmode random:all misc/multiple_suites
+ Should Not Be Equal As Strings ${SUITE.suites} ${DEFAULT SUITE ORDER}
+ ${tests} = Get Tests
+ Should Not Be Equal As Strings ${tests} ${DEFAULT TEST ORDER}
+
+*** Keywords ***
+Check That Default Orders Are Correct
+ Run Tests ${EMPTY} misc/multiple_suites
+ Should Be Equal As Strings ${SUITE.suites} ${DEFAULT SUITE ORDER}
+ Should Be Equal As Strings ${SUITE.suites[0].tests} ${DEFAULT TEST
ORDER}
+
+Get Tests
+ Comment This keyword is needed as there is also one directory suite,
which does not contain tests.
+ ${tests} = Set Variable If '${SUITE.suites[0].name}' == 'Subsuite1'
${SUITE.suites[0].suites[0].tests} ${SUITE.suites[0].tests}
+ [Return] ${tests}
+
=======================================
--- /trunk/atest/robot/cli/runner/runmode.txt Wed May 26 04:50:27 2010
+++ /dev/null
@@ -1,53 +0,0 @@
-*** Settings ***
-Suite Setup Check That Default Orders Are Correct
-Force Tags pybot jybot regression
-Resource atest_resource.txt
-
-*** Variables ***
-${DEFAULT SUITE ORDER} ['Suite
First', 'Subsuite1', 'Suite3', 'Suite4', 'Suite5', 'Suite10', 'Suite
6', 'SUite7', 'suiTe 8', 'Suite 9 Name']
-${DEFAULT TEST ORDER}
['test1', 'test2', 'test3', 'test4', 'test5', 'test6', 'test7', 'test8', 'test9', 'test10', 'test11', 'test12']
-
-*** Test Cases ***
-Randomizing Tests
- [Setup] Run Tests --runmode random:test
misc/multiple_suites/01__suite_first.html
- Should Not Be Equal As Strings ${SUITE.tests} ${DEFAULT TEST ORDER}
-
-Randomizing Suites
- [Setup] Run Tests --runmode RANDOM:SuitE misc/multiple_suites
- Should Not Be Equal As Strings ${SUITE.suites} ${DEFAULT SUITE ORDER}
- ${tests} = Get Tests
- Should Be Equal As Strings ${tests} ${DEFAULT TEST ORDER}
-
-Randomizing Suites And Tests
- [Setup] Run Tests --runmode random:all misc/multiple_suites
- Should Not Be Equal As Strings ${SUITE.suites} ${DEFAULT SUITE ORDER}
- ${tests} = Get Tests
- Should Not Be Equal As Strings ${tests} ${DEFAULT TEST ORDER}
-
-Exit On Failure
- [Setup] Run Tests --runmode exitonfailure misc/pass_and_fail.html
misc/suites
- 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
-
-Correct Suite Teardown Is Executed When Exitonfailure Is Used
- [Setup] Run Tests --runmode exitonfailure misc/suites
- ${tsuite} = Get Test Suite Suites
- Should Be Equal ${tsuite.teardown.name} BuiltIn.Log
- ${tsuite} = Get Test Suite Fourth
- Should Be Equal ${tsuite.teardown.name} BuiltIn.Log
- ${tsuite} = Get Test Suite Tsuite3
- Should Be Equal ${tsuite.teardown} ${None}
-
-*** Keywords ***
-Check That Default Orders Are Correct
- Run Tests ${EMPTY} misc/multiple_suites
- Should Be Equal As Strings ${SUITE.suites} ${DEFAULT SUITE ORDER}
- Should Be Equal As Strings ${SUITE.suites[0].tests} ${DEFAULT TEST
ORDER}
-
-Get Tests
- Comment This keyword is needed as there is also one directory suite,
which does not contain tests.
- ${tests} = Set Variable If '${SUITE.suites[0].name}' == 'Subsuite1'
${SUITE.suites[0].suites[0].tests} ${SUITE.suites[0].tests}
- [Return] ${tests}
-
=======================================
--- /trunk/atest/robot/running/stopping_with_signal.txt Tue Jul 6 03:56:04
2010
+++ /trunk/atest/robot/running/stopping_with_signal.txt Tue Aug 24 03:15:42
2010
@@ -64,16 +64,28 @@
${ts} = Get Test Suite With Teardown
Check Log Message ${ts.teardown.kws[0].msgs[0]} Logging Suite
Teardown
+One Signal Should Stop Test Execution Gracefully And Skip Teardowns With
Runmode
+ Start And Send Signal with_teardown.txt One Signal SIGINT 0s
runmode=SkipTeardownOnExit
+ Process Output For Graceful Shutdown
+ Check Test Cases Have Failed Correctly
+ ${tc} = Get Test Case Test
+ #Should Have Correct Number Of Keywords ${tc.teardown} 0
+ Should Be Equal ${tc.teardown} ${None}
+ ${ts} = Get Test Suite With Teardown
+ #Should Have Correct Number Of Keywords ${ts.teardown} 0
+ Should Be Equal ${ts.teardown} ${None}
+
+
*** Key Words ***
Start And Send Signal
# Timeouts and signals apparently don't work on Windows
# [timeout] 2 minutes
- [arguments] ${testcase file} ${signal method} ${signal} ${teardown
sleep}
+ [arguments] ${testcase file} ${signal method} ${signal} ${teardown
sleep} ${runmode}=normal
${is_jython_in_use} = Running On Jython ${INTERPRETER}
${test signal file} = catenate SEPARATOR=_
robot_signal_test_started ${INTERPRETER} .txt
Remove File ${TEMPDIR}/${test signal file}
- Run Keyword unless ${is_jython_in_use} Start Running Robot ${test
signal file} running/stopping_with_signal/${testcase file} ${teardown
sleep}
- Run Keyword if ${is_jython_in_use} Start Running jybot ${test
signal file} running/stopping_with_signal/${testcase file} ${teardown
sleep}
+ Run Keyword unless ${is_jython_in_use} Start Running Robot ${test
signal file} running/stopping_with_signal/${testcase file} ${teardown
sleep} ${runmode}
+ Run Keyword if ${is_jython_in_use} Start Running jybot ${test
signal file} running/stopping_with_signal/${testcase file} ${teardown
sleep} ${runmode}
Wait Until Created ${TEMPDIR}/${test signal file} 1 minutes
Run Keyword ${signal method} ${signal}
Wait Until Finished With Timeout
@@ -83,21 +95,21 @@
wait until finished
Start Running Robot
- [arguments] ${test signal file} ${datasource} ${teardown sleep}
+ [arguments] ${test signal file} ${datasource} ${teardown sleep}
${runmode}
${runner} = Get Coverage Runner
- Start Run ${runner} ${test signal file} ${datasource} ${teardown
sleep}
+ Start Run ${runner} ${test signal file} ${datasource} ${teardown
sleep} ${runmode}
Start Running Jybot
- [arguments] ${test signal file} ${datasource} ${teardown sleep}
+ [arguments] ${test signal file} ${datasource} ${teardown sleep}
${runmode}
${jybot} = Get Jython Path
- Start Run ${jybot} ${test signal file} ${datasource} ${teardown
sleep}
+ Start Run ${jybot} ${test signal file} ${datasource} ${teardown
sleep} ${runmode}
Start Run
- [arguments] ${runner} ${test signal file} ${datasource} ${teardown
sleep}
+ [arguments] ${runner} ${test signal file} ${datasource} ${teardown
sleep} ${runmode}
Set Runners
${path to datasource} = Set Variables And Get Datasources
${datasource}
${path to runner} = Join Path ${ROBOTPATH} runner.py
- @{command} = Create List ${runner} ${path to runner} --variable
TESTSIGNALFILE:${test signal file} --output ${OUTFILE} --report None
--log None --debugfile ${TEST DEBUG FILE} --variable
TEARDOWNSLEEP:${teardown sleep} ${path to datasource}
+ @{command} = Create List ${runner} ${path to runner} --variable
TESTSIGNALFILE:${test signal file} --output ${OUTFILE} --report None
--log None --debugfile ${TEST DEBUG FILE} --variable
TEARDOWNSLEEP:${teardown sleep} --runmode ${runmode} ${path to
datasource}
Log Many @{command}
ProcessManager.start process @{command}
=======================================
--- /trunk/atest/testdata/misc/suites/fourth.html Mon Jun 9 00:25:53 2008
+++ /trunk/atest/testdata/misc/suites/fourth.html Tue Aug 24 03:15:42 2010
@@ -184,6 +184,13 @@
<td></td>
</tr>
<tr>
+<td></td>
+<td>[Teardown]</td>
+<td>Log</td>
+<td>Huhuu</td>
+<td></td>
+</tr>
+<tr>
<td></td>
<td></td>
<td></td>
=======================================
--- /trunk/src/robot/common/model.py Sat Jul 3 00:58:19 2010
+++ /trunk/src/robot/common/model.py Tue Aug 24 03:15:42 2010
@@ -273,6 +273,8 @@
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':
@@ -296,7 +298,8 @@
self.set_metadata(settings['Metadata'])
self.set_critical_tags(settings['Critical'],
settings['NonCritical'])
try:
- self.set_runmode(settings['RunMode'])
+ for runmode in settings['RunMode']:
+ self.set_runmode(runmode)
except (KeyError, AttributeError) : # Only applicable when running
tcs
pass
if not self.suites:
=======================================
--- /trunk/src/robot/conf/settings.py Mon Aug 23 06:35:19 2010
+++ /trunk/src/robot/conf/settings.py Tue Aug 24 03:15:42 2010
@@ -192,7 +192,7 @@
class RobotSettings(_BaseSettings):
_extra_cli_opts = { 'Output' : ('output', 'output.xml'),
'LogLevel' : ('loglevel', 'INFO'),
- 'RunMode' : ('runmode', 'normal'),
+ 'RunMode' : ('runmode', []),
'Variables' : ('variable', []),
'VariableFiles' : ('variablefile', []),
'Listeners' : ('listener', []),
=======================================
--- /trunk/src/robot/runner.py Mon Aug 23 03:15:52 2010
+++ /trunk/src/robot/runner.py Tue Aug 24 03:15:42 2010
@@ -97,14 +97,14 @@
can be given as a pattern like e.g. with --test.
-n --noncritical tag * Tests with given tag are not critical even if
they
have a tag set with --critical. Tag can be a
pattern.
- --runmode mode Possible values
are 'random:test', 'random:suite',
+ --runmode mode * Possible values
are 'random:test', 'random:suite',
'random:all', 'exitonfailure' and 'dryrun'. Any
other
value is ignored. First three change the
execution
order of suites or tests (or
both). 'exitonfailure'
causes the execution of tests to be stopped if a
critical test fails. In 'dryrun' mode, tests are
run
normally otherwise, but the keywords coming from
test
- libraries are not executed at all.
+ libraries are not executed at all. TODO:
skipteardown
-v --variable name:value * Set variables in the test data. Only scalar
variables are supported and name is given without
'${}'. See --escape for how to use special
characters
=======================================
--- /trunk/src/robot/running/model.py Tue Jun 1 02:58:23 2010
+++ /trunk/src/robot/running/model.py Tue Aug 24 03:15:42 2010
@@ -94,6 +94,7 @@
RunnableTestCase(test, parent=self, defaults=defaults)
self._run_mode_exit_on_failure = False
self._run_mode_dry_run = False
+ self._run_mode_skip_teardowns_on_exit = False
def filter_empty_suites(self):
for suite in self.suites[:]:
@@ -120,7 +121,7 @@
def _start_run(self, output, parent, errors):
if not errors:
- errors = SuiteRunErrors(self._run_mode_exit_on_failure)
+ errors = SuiteRunErrors(self._run_mode_exit_on_failure,
self._run_mode_skip_teardowns_on_exit)
self.run_errors = errors
self.run_errors.start_suite()
self.status = 'RUNNING'
@@ -195,6 +196,7 @@
RunnableTestSuite(suite, parent=self)
self._run_mode_exit_on_failure = False
self._run_mode_dry_run = False
+ self._run_mode_skip_teardowns_on_exit = False
class RunnableTestCase(BaseTestCase):
@@ -258,7 +260,7 @@
def keyword_failed(self, err):
self.timeout.set_keyword_timeout(err.timeout)
- self._suite_errors.test_failed(exit=err.exit)
+ self._suite_errors.test_failed(exit=err.exit,
critical=self.critical=='yes')
def _run_setup(self, context):
self.setup.run(context, TestSetupListener(self))
@@ -273,7 +275,8 @@
return self.message, self.status
def _run_teardown(self, context):
- self.teardown.run(context, TestTeardownListener(self))
+ if self._suite_errors.is_test_teardown_allowed():
+ self.teardown.run(context, TestTeardownListener(self))
def _report_status_after_teardown(self):
if self.run_errors.teardown_failed():
=======================================
--- /trunk/src/robot/running/runerrors.py Thu Aug 12 07:13:22 2010
+++ /trunk/src/robot/running/runerrors.py Tue Aug 24 03:15:42 2010
@@ -21,8 +21,9 @@
_parent_suite_setup_error = 'Setup of the parent suite failed.'
- def __init__(self, run_mode_is_exit_on_failure=False):
+ 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
self._earlier_init_errors = []
self._earlier_setup_errors = []
self._earlier_suite_setup_executions = []
@@ -50,11 +51,18 @@
not self._earlier_errors()
def is_suite_teardown_allowed(self):
+ if not self.is_test_teardown_allowed():
+ return False
if self._current_suite_setup_executed:
return True
return self._current_init_err is self._NO_ERROR and \
not self._earlier_errors()
+ def is_test_teardown_allowed(self):
+ if not self._run_mode_skip_teardowns_on_exit:
+ return True
+ return not (self._exit_fatal or self._exit_runmode)
+
def _earlier_errors(self):
if self._exit_runmode or self._exit_fatal:
return True