Revision: 3189
Author: pekka.klarck
Date: Wed May  5 07:23:13 2010
Log: Report parsing time syntax errors and syntax errors inside for loop correctly. Only added tests for Run Kw And Ignore/Expect Error for this because others access the same attribute as these ones.
http://code.google.com/p/robotframework/source/detail?r=3189

Modified:
 /trunk/atest/robot/standard_libraries/builtin/run_keyword_with_errors.txt
/trunk/atest/testdata/standard_libraries/builtin/run_keyword_with_errors.txt
 /trunk/src/robot/running/keywords.py

=======================================
--- /trunk/atest/robot/standard_libraries/builtin/run_keyword_with_errors.txt Thu Apr 22 06:01:01 2010 +++ /trunk/atest/robot/standard_libraries/builtin/run_keyword_with_errors.txt Wed May 5 07:23:13 2010
@@ -42,8 +42,15 @@
 Ignore Error When Timeout Occurs In UK
     Check Test Case  ${TEST NAME}

-Ignore Error When Syntax Error
+Ignore Error When Syntax Error At Parsing Time
     Check Test Case  ${TEST NAME}
+
+Ignore Error When Syntax Error At Run Time
+    Check Test Case  ${TEST NAME}
+
+Ignore Error When Syntax Error In For Loop
+    Check Test Case  ${TEST NAME}
+

 Expect Error When Error Occurs
     ${tc} =  Check Test Case  Expect Error When Error Occurs
@@ -90,7 +97,13 @@
 Expect Error When Timeout Occurs In UK
     Check Test Case  ${TEST NAME}

-Expect Error When Syntax Error
+Expect Error When Syntax Error At Parsing Time
+    Check Test Case  ${TEST NAME}
+
+Expect Error When Syntax Error At Run Time
+    Check Test Case  ${TEST NAME}
+
+Expect Error When Syntax Error In For Loop
     Check Test Case  ${TEST NAME}

 Variable Values Should Not Be Visible As Keyword's Arguments
=======================================
--- /trunk/atest/testdata/standard_libraries/builtin/run_keyword_with_errors.txt Thu Apr 22 06:01:01 2010 +++ /trunk/atest/testdata/standard_libraries/builtin/run_keyword_with_errors.txt Wed May 5 07:23:13 2010
@@ -51,10 +51,18 @@
     [Documentation]  FAIL  Keyword timeout 100 milliseconds exceeded.
     Run Keyword And Ignore Error  Timeouting UK

-Ignore Error When Syntax Error
+Ignore Error When Syntax Error At Parsing Time
+    [Documentation]  FAIL  Syntax error: No keyword specified
+    Run Keyword And Ignore Error  Broken User Keyword
+
+Ignore Error When Syntax Error At Run Time
[Documentation] FAIL Keyword 'BuiltIn.No Operation' expected 0 arguments, got 4. Run Keyword And Ignore Error No Operation wrong number of arguments

+Ignore Error When Syntax Error In For Loop
+    [Documentation]  FAIL  Non-existing variable '\${nonex}'
+    Run Keyword And Ignore Error  For Loop With Syntax Error
+

 Expect Error When Error Occurs
Run Keyword And Expect Error ${ERROR MESSAGE} ${FAIL KW} ${ERROR MESSAGE}
@@ -107,9 +115,17 @@
     [Documentation]  FAIL  Keyword timeout 100 milliseconds exceeded.
     Run Keyword And Expect Error  *  Timeouting UK

-Expect Error When Syntax Error
- [Documentation] FAIL Keyword 'BuiltIn.No Operation' expected 0 arguments, got 4. - Run Keyword And Expect Error * No Operation wrong number of arguments
+Expect Error When Syntax Error At Parsing Time
+    [Documentation]  FAIL  Syntax error: No keyword specified
+    Run Keyword And Expect Error  *  Broken User Keyword
+
+Expect Error When Syntax Error At Run Time
+ [Documentation] FAIL No keyword with name 'Non existing keyword' found.
+    Run Keyword And Expect Error  *  Non existing keyword
+
+Expect Error When Syntax Error In For Loop
+    [Documentation]  FAIL  Non-existing variable '\${nonex}'
+    Run Keyword And Expect Error  *  For Loop With Syntax Error


 *** Keywords ***
@@ -127,3 +143,10 @@
 Timeouting UK
     [Timeout]  0.1 seconds
     Run Keyword And Ignore Error  Sleep  1 hour
+
+For Loop With Syntax Error
+    :FOR  ${a}  IN  ${nonex}
+    \   Whatever
+
+Broken User Keyword
+    ${x}
=======================================
--- /trunk/src/robot/running/keywords.py        Wed May  5 07:20:37 2010
+++ /trunk/src/robot/running/keywords.py        Wed May  5 07:23:13 2010
@@ -241,7 +241,7 @@
         except DataError, err:
             msg = unicode(err)
             output.fail(msg)
-            error = ExecutionFailed(msg)
+            error = ExecutionFailed(msg, syntax=True)
         else:
             error = None
         self.status = 'PASS' if not error else 'FAIL'
@@ -330,4 +330,4 @@
         self.endtime = utils.get_timestamp()
self.elapsedtime = utils.get_elapsed_time(self.starttime, self.endtime)
         output.end_keyword(self)
-        raise ExecutionFailed(self._error)
+        raise ExecutionFailed(self._error, syntax=True)

Reply via email to