Revision: cfc0c9f27c2e
Branch: default
Author: Robot Framework Developers (robotframew...@gmail.com)
Date: Tue Jan 21 13:16:05 2014 UTC
Log: Remote: Support continuable and fatal errors.
Update issue 1628
Owner: pekka.klarck
Status: Started
Implemented Remote library side of the new functionality.
Final decision was to add new optional 'continuable' and 'fatal' keys to the
result dictionary. If these keys are present, and the value is True, the
situation will be reported to Robot accordingly. These values are only used
if
the keyword fails, and if both values are set then 'fatal' has precedence.
http://code.google.com/p/robotframework/source/detail?r=cfc0c9f27c2e
Added:
/atest/robot/standard_libraries/remote/special_errors.txt
/atest/testdata/standard_libraries/remote/special_errors.txt
/atest/testdata/standard_libraries/remote/specialerrors.py
Modified:
/atest/testdata/standard_libraries/remote/simple_server.txt
/src/robot/errors.py
/src/robot/libraries/Remote.py
=======================================
--- /dev/null
+++ /atest/robot/standard_libraries/remote/special_errors.txt Tue Jan 21
13:16:05 2014 UTC
@@ -0,0 +1,20 @@
+*** Settings ***
+Suite Setup Run Remote Tests special_errors.txt specialerrors.py
+Force Tags regression pybot jybot
+Resource remote_resource.txt
+
+*** Test Cases ***
+Continuable
+ ${tc} = Check Test Case ${TEST NAME}
+ Check Log Message ${tc.kws[0].msgs[0]} message FAIL
+ Check Log Message ${tc.kws[0].msgs[1]} trace1 DEBUG
+ Check Log Message ${tc.kws[1].msgs[0]} second message FAIL
+ Check Log Message ${tc.kws[1].msgs[1]} trace2 DEBUG
+ Check Log Message ${tc.kws[2].msgs[0]} third message FAIL
+ Check Log Message ${tc.kws[2].msgs[1]} trace3 DEBUG
+
+Fatal
+ ${tc} = Check Test Case ${TEST NAME}
+ Check Log Message ${tc.kws[0].msgs[0]} Execution ends here
FAIL
+ Check Log Message ${tc.kws[0].msgs[1]} with this traceback
DEBUG
+ Check Test Case Fails due to earlier fatal error
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/remote/special_errors.txt Tue Jan 21
13:16:05 2014 UTC
@@ -0,0 +1,26 @@
+*** Settings ***
+Documentation Continuable and fatal errors.
+Library Remote 127.0.0.1:${PORT}
+Suite Setup Set Log Level DEBUG
+
+*** Variables ***
+${PORT} 8270
+
+*** Test Cases ***
+Continuable
+ [Documentation] FAIL Several failures occurred:\n\n
+ ... 1) message\n\n
+ ... 2) second message\n\n
+ ... 3) third message
+ Continuable message trace1
+ Continuable second message trace2
+ Continuable third message trace3
+
+Fatal
+ [Documentation] FAIL Execution ends here
+ Fatal Execution ends here with this traceback
+ Fail This should not be executed
+
+Fails due to earlier fatal error
+ [Documentation] FAIL Test execution stopped due to a fatal error.
+ Fail This should not be executed
=======================================
--- /dev/null
+++ /atest/testdata/standard_libraries/remote/specialerrors.py Tue Jan 21
13:16:05 2014 UTC
@@ -0,0 +1,20 @@
+import sys
+from remoteserver import DirectResultRemoteServer
+
+
+class SpecialErrors(object):
+
+ def continuable(self, message, traceback):
+ return self._special_error(message, traceback, continuable=True)
+
+ def fatal(self, message, traceback):
+ return self._special_error(message, traceback,
+ fatal='this wins', continuable=42)
+
+ def _special_error(self, message, traceback, continuable=False,
fatal=False):
+ return {'status': 'FAIL', 'error': message, 'traceback': traceback,
+ 'continuable': continuable, 'fatal': fatal}
+
+
+if __name__ == '__main__':
+ DirectResultRemoteServer(SpecialErrors(), *sys.argv[1:])
=======================================
--- /atest/testdata/standard_libraries/remote/simple_server.txt Sun Dec 15
00:27:17 2013 UTC
+++ /atest/testdata/standard_libraries/remote/simple_server.txt Tue Jan 21
13:16:05 2014 UTC
@@ -15,10 +15,12 @@
Failing
[Documentation] FAIL Teh error messaz
Failing Teh error messaz
+ Fail This should not be executed
Failing with traceback
[Documentation] FAIL RemoteError
Traceback Teh trazeback
+ Fail This should not be executed
Returning
${ret} = Returning
=======================================
--- /src/robot/errors.py Thu Jun 6 14:00:44 2013 UTC
+++ /src/robot/errors.py Tue Jan 21 13:16:05 2014 UTC
@@ -239,3 +239,8 @@
class RemoteError(RobotError):
"""Used by Remote library to report remote errors."""
+
+ def __init__(self, message='', details='', fatal=False,
continuable=False):
+ RobotError.__init__(self, message, details)
+ self.ROBOT_EXIT_ON_FAILURE = fatal
+ self.ROBOT_CONTINUE_ON_FAILURE = continuable
=======================================
--- /src/robot/libraries/Remote.py Thu Jan 9 17:07:21 2014 UTC
+++ /src/robot/libraries/Remote.py Tue Jan 21 13:16:05 2014 UTC
@@ -67,7 +67,8 @@
result = RemoteResult(self._client.run_keyword(name, args, kwargs))
sys.stdout.write(result.output)
if result.status != 'PASS':
- raise RemoteError(result.error, result.traceback)
+ raise RemoteError(result.error, result.traceback, result.fatal,
+ result.continuable)
return result.return_
@@ -144,9 +145,11 @@
self.return_ = self._get(result, 'return')
self.error = self._get(result, 'error')
self.traceback = self._get(result, 'traceback')
+ self.fatal = bool(self._get(result, 'fatal', False))
+ self.continuable = bool(self._get(result, 'continuable', False))
- def _get(self, result, key):
- value = result.get(key, '')
+ def _get(self, result, key, default=''):
+ value = result.get(key, default)
return self._handle_binary(value)
def _handle_binary(self, value):
--
---
You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.