Revision: e086f9837c65
Branch:   default
Author:   Pekka Klärck
Date:     Tue Apr 22 13:31:58 2014 UTC
Log: Fix `BuiltIn.Run Keyword And Return (If)` when return value needs to be escaped

Update issue 1684
Status: Done
Fixed Run Keyword And Return and that automatically also fixed Run Keyword And Return If. Also added tests for both.
http://code.google.com/p/robotframework/source/detail?r=e086f9837c65

Modified:
 /atest/robot/standard_libraries/builtin/run_keyword_and_return.txt
 /atest/testdata/standard_libraries/builtin/run_keyword_and_return.txt
 /src/robot/libraries/BuiltIn.py

=======================================
--- /atest/robot/standard_libraries/builtin/run_keyword_and_return.txt Tue Nov 26 13:53:15 2013 UTC +++ /atest/robot/standard_libraries/builtin/run_keyword_and_return.txt Tue Apr 22 13:31:58 2014 UTC
@@ -37,6 +37,9 @@

 With list variable containing escaped items
     Check Test Case    ${TESTNAME}
+
+Return strings that needs to be escaped
+    Check Test Case    ${TESTNAME}

 Run Keyword And Return If
     ${tc} =    Check Test Case    ${TESTNAME}
@@ -49,3 +52,6 @@

 Run Keyword And Return If with list variable containing escaped items
     Check Test Case    ${TESTNAME}
+
+Run Keyword And Return If return strings that needs to be escaped
+    Check Test Case    ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/builtin/run_keyword_and_return.txt Tue Nov 26 12:56:51 2013 UTC +++ /atest/testdata/standard_libraries/builtin/run_keyword_and_return.txt Tue Apr 22 13:31:58 2014 UTC
@@ -48,6 +48,14 @@
${ret} = Run Keyword And Return With Variables Create List @{ESCAPING}
     Should Be Equal    ${ret}    ${ESCAPING}
     Run Keyword And Return With Variables    @{ESCAPING}
+
+Return strings that needs to be escaped
+    ${ret} =    Run Keyword And Return Given Args    \${not var}
+    Should Be Equal    ${ret}    \${not var}
+    ${ret} =    Run Keyword And Return Given Args    c:\\temp\\new
+    Should Be Equal    ${ret}    c:\\temp\\new
+    ${ret} =    Run Keyword And Return Given Args    @{ESCAPING}
+    Should Be Equal    ${ret}    ${ESCAPING}

 Run Keyword And Return If
     ${ret} =    Run Keyword And Return If Arg Is Positive
@@ -67,6 +75,15 @@
     Should Be Equal    ${ret}    ${ESCAPING}
     Run Keyword And Return If With Variables    @{ESCAPING}

+Run Keyword And Return If return strings that needs to be escaped
+    ${ret} =    Run Keyword And Return Given Args If    True    \${not var}
+    Should Be Equal    ${ret}    \${not var}
+ ${ret} = Run Keyword And Return Given Args If True c:\\temp\\new
+    Should Be Equal    ${ret}    c:\\temp\\new
+ ${ret} = Run Keyword And Return Given Args If 1 > 0 @{ESCAPING}
+    Should Be Equal    ${ret}    ${ESCAPING}
+ ${ret} = Run Keyword And Return Given Args If False @{ESCAPING}
+    Should Be Equal    ${ret}    ${NONE}

 *** Keywords ***
 Return one value
@@ -132,6 +149,14 @@
 Run Keyword And Return With Variables
     [Arguments]    @{args}
     Run Keyword And Return    @{args}
+
+Run Keyword And Return Given Args
+    [Arguments]    @{return}
+    Run Keyword And Return    Set Variable    @{return}
+
+Run Keyword And Return Given Args If
+    [Arguments]    ${condition}    @{return}
+    Run Keyword And Return If    ${condition}    Set Variable    @{return}

 Run Keyword And Return If Arg Is Positive
     [Arguments]    @{args}
=======================================
--- /src/robot/libraries/BuiltIn.py     Thu Apr 17 11:45:07 2014 UTC
+++ /src/robot/libraries/BuiltIn.py     Tue Apr 22 13:31:58 2014 UTC
@@ -1857,7 +1857,7 @@
         New in Robot Framework 2.8.2.
         """
         ret = self.run_keyword(name, *args)
-        self.return_from_keyword(ret)
+        self.return_from_keyword(utils.escape(ret))

     @run_keyword_variant(resolve=2)
     def run_keyword_and_return_if(self, condition, name, *args):

--

--- 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/d/optout.

Reply via email to