2 new revisions:

Revision: a80b6021234d
Branch:   default
Author:   Pekka Klärck
Date:     Thu Nov 28 15:40:56 2013 UTC
Log: Disabled Java argument coercion in dryrun when args contain variables....
http://code.google.com/p/robotframework/source/detail?r=a80b6021234d

Revision: 6c826f58e0b2
Branch:   default
Author:   Pekka Klärck
Date:     Thu Nov 28 15:41:06 2013 UTC
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=6c826f58e0b2

==============================================================================
Revision: a80b6021234d
Branch:   default
Author:   Pekka Klärck
Date:     Thu Nov 28 15:40:56 2013 UTC
Log: Disabled Java argument coercion in dryrun when args contain variables.

Update issue 1592
Status: Done
Fixed with tests. Contains tests also for issue 1589.
http://code.google.com/p/robotframework/source/detail?r=a80b6021234d

Added:
 /atest/robot/cli/dryrun/java_arguments.txt
Modified:
 /src/robot/running/arguments/javaargumentcoercer.py
 /src/robot/running/handlers.py
 /src/robot/variables/__init__.py
 /src/robot/variables/isvar.py

=======================================
--- /dev/null
+++ /atest/robot/cli/dryrun/java_arguments.txt  Thu Nov 28 15:40:56 2013 UTC
@@ -0,0 +1,62 @@
+*** Settings ***
+Suite Setup      Run Tests    --dryrun    keywords/java_arguments.txt
+Force Tags       regression    jybot
+Resource         atest_resource.txt
+
+*** Test Cases ***
+Correct Number Of Arguments When No Defaults Or Varargs
+    Check Test Case    ${TESTNAME}
+
+Too Few Arguments When No Defaults Or Varargs
+    Check Test Case    ${TESTNAME} 1
+    Check Test Case    ${TESTNAME} 2
+
+Too Many Arguments When No Defaults Or Varargs
+    Check Test Case    ${TESTNAME} 1
+    Check Test Case    ${TESTNAME} 2
+    Check Test Case    ${TESTNAME} 3
+
+Correct Number Of Arguments With Defaults
+    Check Test Case    ${TESTNAME}
+
+Java Varargs Should Work
+    Check Test Case    ${TESTNAME}
+
+Too Few Arguments With Defaults
+    Check Test Case    ${TESTNAME}
+
+Too Many Arguments With Defaults
+    Check Test Case    ${TESTNAME} 1
+    Check Test Case    ${TESTNAME} 2
+
+Correct Number Of Arguments With Varargs
+    Check Test Case    ${TESTNAME}
+
+Too Few Arguments With Varargs
+    Check Test Case    ${TESTNAME}
+
+Too Few Arguments With Varargs List
+    Check Test Case    ${TESTNAME}
+
+Varargs Work Also With Arrays
+    Check Test Case    ${TESTNAME}
+
+Varargs Work Also With Lists
+    Check Test Case    ${TESTNAME}
+
+Invalid Argument Types
+    Check Test Case    ${TESTNAME} 1
+
+Invalid Argument Values Are Not Checked
+    Check Test Case    Invalid Argument Types 3    PASS    ${EMPTY}
+
+Arguments with variables are not coerced
+    Check Test Case    Invalid Argument Types 2    PASS    ${EMPTY}
+    Check Test Case    Invalid Argument Types 3    PASS    ${EMPTY}
+    Check Test Case    Invalid Argument Types 4    PASS    ${EMPTY}
+    Check Test Case    Invalid Argument Types 5    PASS    ${EMPTY}
+    Check Test Case    Invalid Argument Types 6    PASS    ${EMPTY}
+    Check Test Case    Invalid Argument Types 7    PASS    ${EMPTY}
+
+Calling Using List Variables
+    Check Test Case    ${TESTNAME}
=======================================
--- /src/robot/running/arguments/javaargumentcoercer.py Thu Jun 6 14:00:44 2013 UTC +++ /src/robot/running/arguments/javaargumentcoercer.py Thu Nov 28 15:40:56 2013 UTC
@@ -14,6 +14,8 @@

 from java.lang import Byte, Short, Integer, Long, Boolean, Float, Double

+from robot.variables import contains_var
+

 class JavaArgumentCoercer(object):

@@ -21,9 +23,9 @@
         self._coercers = CoercerFinder().find_coercers(signatures)
         self._varargs_handler = VarargsHandler(argspec)

-    def coerce(self, arguments):
+    def coerce(self, arguments, dryrun=False):
         arguments = self._varargs_handler.handle(arguments)
-        return [c.coerce(a) for c, a in zip(self._coercers, arguments)]
+ return [c.coerce(a, dryrun) for c, a in zip(self._coercers, arguments)]


 class CoercerFinder(object):
@@ -67,8 +69,9 @@
     def handles(self, type):
         return type in self._types or type.__name__ in self._primitives

-    def coerce(self, argument):
-        if not isinstance(argument, basestring):
+    def coerce(self, argument, dryrun=False):
+        if not isinstance(argument, basestring) \
+                or (dryrun and contains_var(argument)):
             return argument
         try:
             return self._coerce(argument)
@@ -115,7 +118,7 @@
     def handles(self, argument):
         return True

-    def coerce(self, argument):
+    def _coerce(self, argument):
         return argument


=======================================
--- /src/robot/running/handlers.py      Thu Nov 28 14:49:09 2013 UTC
+++ /src/robot/running/handlers.py      Thu Nov 28 15:40:56 2013 UTC
@@ -189,7 +189,7 @@

     def resolve_arguments(self, args, variables=None):
positional, named = self._argument_resolver.resolve(args, variables)
-        positional = self._arg_coercer.coerce(positional)
+ positional = self._arg_coercer.coerce(positional, dryrun=not variables)
         return positional, named


=======================================
--- /src/robot/variables/__init__.py    Tue Nov 19 13:19:28 2013 UTC
+++ /src/robot/variables/__init__.py    Thu Nov 28 15:40:56 2013 UTC
@@ -24,7 +24,7 @@
 from robot import utils
 from robot.output import LOGGER

-from .isvar import is_var, is_scalar_var, is_list_var
+from .isvar import contains_var, is_var, is_scalar_var, is_list_var
 from .variables import Variables
 from .variableassigner import VariableAssigner
 from .variablesplitter import VariableSplitter, VariableIterator
=======================================
--- /src/robot/variables/isvar.py       Thu Jun  6 14:00:44 2013 UTC
+++ /src/robot/variables/isvar.py       Thu Nov 28 15:40:56 2013 UTC
@@ -12,6 +12,8 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

+from .variablesplitter import VariableIterator
+

 def is_var(string):
     if not isinstance(string, basestring):
@@ -27,3 +29,8 @@

 def is_list_var(string):
     return is_var(string) and string[0] == '@'
+
+
+def contains_var(string):
+    return bool(isinstance(string, basestring) and
+                VariableIterator(string, '$@'))

==============================================================================
Revision: 6c826f58e0b2
Branch:   default
Author:   Pekka Klärck
Date:     Thu Nov 28 15:41:06 2013 UTC
Log:      Automated merge with https://code.google.com/p/robotframework/
http://code.google.com/p/robotframework/source/detail?r=6c826f58e0b2


--

--- 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to