4 new revisions:

Revision: 00a5ff93fead
Branch:   default
Author:   Pekka Klärck
Date:     Fri May 24 09:04:44 2013
Log:      new run: tuning setting status and message
http://code.google.com/p/robotframework/source/detail?r=00a5ff93fead

Revision: 671186e04db1
Branch:   default
Author:   Pekka Klärck
Date:     Fri May 24 12:54:23 2013
Log:      new run: fixed import in init files
http://code.google.com/p/robotframework/source/detail?r=671186e04db1

Revision: 149e9fd0a7c8
Branch:   default
Author:   Pekka Klärck
Date:     Sun May 26 01:12:36 2013
Log: new run: build setups/teardowns as any other keyword. requires API com...
http://code.google.com/p/robotframework/source/detail?r=149e9fd0a7c8

Revision: 1aca34f64caf
Branch:   default
Author:   Pekka Klärck
Date:     Sun May 26 01:39:58 2013
Log: model and result building: Changed arguments to be tuples, not lists....
http://code.google.com/p/robotframework/source/detail?r=1aca34f64caf

==============================================================================
Revision: 00a5ff93fead
Branch:   default
Author:   Pekka Klärck
Date:     Fri May 24 09:04:44 2013
Log:      new run: tuning setting status and message
http://code.google.com/p/robotframework/source/detail?r=00a5ff93fead

Modified:
 /src/robot/new_running/failures.py
 /src/robot/new_running/runner.py
 /utest/new_running/test_running.py

=======================================
--- /src/robot/new_running/failures.py  Fri May 24 06:50:08 2013
+++ /src/robot/new_running/failures.py  Fri May 24 09:04:44 2013
@@ -15,12 +15,13 @@

 class ExecutionStatus(object):

-    def __init__(self, parent_status=None):
+    def __init__(self, parent_status=None, test=False):
         self.parent_status = parent_status
         self.setup_failure = None
         self.test_failure = None
         self.teardown_failure = None
         self.teardown_allowed = False
+        self._test = test

     def setup_executed(self, failure=None):
         if failure:
@@ -37,8 +38,12 @@
     @property
     def message(self):
         if self.parent_status and self.parent_status.failures:
-            return ParentMessageCreator(self.parent_status).create()
-        return MessageCreator(self).create()
+            message = ParentMessage(self.parent_status)
+        elif self._test:
+            message = TestMessage(self)
+        else:
+            message = SuiteMessage(self)
+        return unicode(message)

     @property
     def failures(self):
@@ -47,11 +52,15 @@
                     self.test_failure or
                     self.teardown_failure)

+    @property
+    def status(self):
+        return 'FAIL' if self.failures else 'PASS'
+

 # TODO: Messages below are not identical to old run messages!!
 # Remember to also update messages in SuiteTeardownFailureHandler

-class MessageCreator(object):
+class TestMessage(object):
     setup_failed = 'Setup failed:\n%s'
     teardown_failed = 'Teardown failed:\n%s'
     also_teardown_failed = '%s\n\nAlso teardown failed:\n%s'
@@ -61,7 +70,7 @@
         self.test = status.test_failure or ''
         self.teardown = status.teardown_failure

-    def create(self):
+    def __unicode__(self):
         msg = self._get_message_before_teardown()
         return self._get_message_after_teardown(msg)

@@ -78,5 +87,13 @@
         return self.also_teardown_failed % (msg, self.teardown)


-class ParentMessageCreator(MessageCreator):
+class SuiteMessage(TestMessage):
+    setup_failed = 'Suite setup failed:\n%s'
+    teardown_failed = 'Suite teardown failed:\n%s'
+    also_teardown_failed = '%s\n\nAlso suite teardown failed:\n%s'
+
+
+class ParentMessage(SuiteMessage):
     setup_failed = 'Parent suite setup failed:\n%s'
+    teardown_failed = 'Parent suite teardown failed:\n%s'
+    also_teardown_failed = '%s\n\nAlso parent suite teardown failed:\n%s'
=======================================
--- /src/robot/new_running/runner.py    Fri May 24 06:50:08 2013
+++ /src/robot/new_running/runner.py    Fri May 24 09:04:44 2013
@@ -92,7 +92,7 @@
         if test.timeout:
test.timeout.replace_variables(self._variables) # FIXME: Should not change model state!!
             test.timeout.start()
-        status = ExecutionStatus(self._suite_status)
+        status = ExecutionStatus(self._suite_status, test=True)
         if not status.failures:
             self._run_setup(test.keywords.setup, status)
         try:
@@ -100,10 +100,12 @@
                 keywords.run(self._context)
         except ExecutionFailed, err:
             status.test_failed(err)
+        result.status = status.status
+        result.message = status.message
         if status.teardown_allowed:
             self._run_teardown(test.keywords.teardown, status)
+        result.status = status.status
         result.message = status.message
-        result.status = 'FAIL' if status.failures else 'PASS'
         result.endtime = utils.get_timestamp()
         self._context.end_test(result)

=======================================
--- /utest/new_running/test_running.py  Fri May 24 06:50:08 2013
+++ /utest/new_running/test_running.py  Fri May 24 09:04:44 2013
@@ -136,7 +136,7 @@
     def test_failing_setup(self):
         suite = run(self.suite, variable='SUITE SETUP:Fail')
         assert_suite(suite, 'Setups And Teardowns', 'FAIL',
-                     'Setup failed:\nAssertionError', 4)
+                     'Suite setup failed:\nAssertionError', 4)
         assert_test(suite.tests[0], 'Test with setup and teardown', 'FAIL',
                     msg='Parent suite setup failed:\nAssertionError')

@@ -146,15 +146,15 @@
     def test_failing_teardown(self):
         suite = run(self.suite, variable='SUITE TEARDOWN:Fail')
         assert_suite(suite, 'Setups And Teardowns', 'FAIL',
-                     'Teardown failed:\nAssertionError', 4)
+                     'Suite teardown failed:\nAssertionError', 4)
         assert_test(suite.tests[0], 'Test with setup and teardown', 'FAIL',
msg='Teardown of the parent suite failed:\nAssertionError')

     def test_failing_test_with_failing_teardown(self):
suite = run(self.suite, variable=['SUITE SETUP:Fail', 'SUITE TEARDOWN:Fail'])
         assert_suite(suite, 'Setups And Teardowns', 'FAIL',
-                     'Setup failed:\nAssertionError\n\n'
-                     'Also teardown failed:\nAssertionError', 4)
+                     'Suite setup failed:\nAssertionError\n\n'
+                     'Also suite teardown failed:\nAssertionError', 4)
         assert_test(suite.tests[0], 'Test with setup and teardown', 'FAIL',
                     msg='Parent suite setup failed:\nAssertionError\n\n'
'Also teardown of the parent suite failed:\nAssertionError')
@@ -165,10 +165,10 @@
         root.suites.append(self.suite)
suite = run(root, variable=['SUITE SETUP:Fail', 'SUITE TEARDOWN:Fail'])
         assert_suite(suite, 'Root', 'FAIL',
-                     'Teardown failed:\nTop level', 0)
+                     'Suite teardown failed:\nTop level', 0)
         assert_suite(suite.suites[0], 'Setups And Teardowns', 'FAIL',
-                     'Setup failed:\nAssertionError\n\n'
-                     'Also teardown failed:\nAssertionError', 4)
+                     'Suite setup failed:\nAssertionError\n\n'
+                     'Also suite teardown failed:\nAssertionError', 4)
assert_test(suite.suites[0].tests[0], 'Test with setup and teardown', 'FAIL',
                     msg='Parent suite setup failed:\nAssertionError\n\n'
'Also teardown of the parent suite failed:\nAssertionError\n\n'

==============================================================================
Revision: 671186e04db1
Branch:   default
Author:   Pekka Klärck
Date:     Fri May 24 12:54:23 2013
Log:      new run: fixed import in init files
http://code.google.com/p/robotframework/source/detail?r=671186e04db1

Modified:
 /src/robot/new_running/model.py

=======================================
--- /src/robot/new_running/model.py     Fri May 24 03:05:28 2013
+++ /src/robot/new_running/model.py     Fri May 24 12:54:23 2013
@@ -165,7 +165,11 @@

     @property
     def directory(self):
-        return os.path.dirname(self.source) if self.source else None
+        if not self.source:
+            return None
+        if os.path.isdir(self.source):
+            return self.source
+        return os.path.dirname(self.source)

     # TODO: Error reporting doesn't belong here
     def report_invalid_syntax(self, message, level='ERROR'):

==============================================================================
Revision: 149e9fd0a7c8
Branch:   default
Author:   Pekka Klärck
Date:     Sun May 26 01:12:36 2013
Log: new run: build setups/teardowns as any other keyword. requires API compatibility changes also to parsing.
http://code.google.com/p/robotframework/source/detail?r=149e9fd0a7c8

Modified:
 /src/robot/new_running/builder.py
 /src/robot/parsing/settings.py

=======================================
--- /src/robot/new_running/builder.py   Wed May 22 15:27:57 2013
+++ /src/robot/new_running/builder.py   Sun May 26 01:12:36 2013
@@ -40,8 +40,8 @@
                           metadata=self._get_metadata(data.setting_table))
         for import_data in data.setting_table.imports:
             self._create_import(suite, import_data)
- self._create_fixture(suite, data.setting_table.suite_setup, 'setup') - self._create_fixture(suite, data.setting_table.suite_teardown, 'teardown')
+        self._create_step(suite, data.setting_table.suite_setup, 'setup')
+ self._create_step(suite, data.setting_table.suite_teardown, 'teardown')
         for var_data in data.variable_table.variables:
             self._create_variable(suite, var_data)
         for uk_data in data.keyword_table.keywords:
@@ -68,10 +68,10 @@
                                   tags=values.tags.value,
                                   timeout=TestTimeout(values.timeout.value,
values.timeout.message))
-        self._create_fixture(test, values.setup, 'setup')
+        self._create_step(test, values.setup, 'setup')
         for step_data in data.steps:
             self._create_step(test, step_data)
-        self._create_fixture(test, values.teardown, 'teardown')
+        self._create_step(test, values.teardown, 'teardown')

     def _create_user_keyword(self, suite, data):
         # TODO: Tests and uks have inconsistent timeout types
@@ -92,27 +92,20 @@
             value = data.value
         suite.variables.create(name=data.name, value=value)

-    def _create_fixture(self, parent, data, fixture_type):
-        if data:
-            parent.keywords.create(type=fixture_type,
-                                   name=data.name,
-                                   args=tuple(data.args))
-
-    def _create_step(self, parent, data):
-        if not data.is_for_loop():
-            self._create_normal_step(parent, data)
+    def _create_step(self, parent, data, type='kw'):
+        if not data or data.is_comment():
+            return
+        if data.is_for_loop():
+            self._create_for_loop(parent, data)
         else:
-            self._create_for_loop(parent, data)
-
-    def _create_normal_step(self, parent, data):
-        if not data.is_comment():
             parent.keywords.create(name=data.keyword,
                                    args=tuple(data.args),
-                                   assign=tuple(data.assign))
+                                   assign=tuple(data.assign),
+                                   type=type)

     def _create_for_loop(self, parent, data):
         loop = parent.keywords.append(ForLoop(vars=data.vars,
                                               items=data.items,
                                               range=data.range))
         for step in data.steps:
-            self._create_normal_step(loop, step)
+            self._create_step(loop, step)
=======================================
--- /src/robot/parsing/settings.py      Thu May 16 06:01:15 2013
+++ /src/robot/parsing/settings.py      Sun May 26 01:12:36 2013
@@ -135,9 +135,19 @@

 class Fixture(Setting):

+ # `keyword`, `is_comment` and `assign` make the API compatible with Step.
+
+    @property
+    def keyword(self):
+        return self.name
+
+    def is_comment(self):
+        return False
+
     def _set_initial_value(self):
         self.name = None
         self.args = []
+        self.assign = ()

     def _populate(self, value):
         if not self.name:

==============================================================================
Revision: 1aca34f64caf
Branch:   default
Author:   Pekka Klärck
Date:     Sun May 26 01:39:58 2013
Log: model and result building: Changed arguments to be tuples, not lists.

New run model already build args as tuples, but empty tuples were turned
into empty lists behind the scenes. Now the API is consistent.

The change saves memory on result building because empty tuples are
singletons and thus take a lot less memory than empty lists. Small
tuples also take less memory than small lists in general.

Building results was changed from `args.append('arg')` to `args += ('arg',)`.
Because the number of args is small, there is no performance penalty.

I tested processing output originating from running Robot's acceptance
tests both before and after the change. This confirmed that a little
memory was saved (155MB->150MB) and performance was the same. With
results containing lot of keywords memory savings could be bigger.
http://code.google.com/p/robotframework/source/detail?r=1aca34f64caf

Modified:
 /atest/robot/cli/rebot/remove_keywords/all_and_passed.txt
 /atest/robot/cli/rebot/remove_keywords/remove_keywords_resource.txt
 /atest/robot/keywords/repeating_keyword.txt
 /src/robot/model/keyword.py
 /src/robot/result/keyword.py
 /src/robot/result/xmlelementhandlers.py
 /utest/result/test_resultbuilder.py

=======================================
--- /atest/robot/cli/rebot/remove_keywords/all_and_passed.txt Fri Mar 22 08:36:33 2013 +++ /atest/robot/cli/rebot/remove_keywords/all_and_passed.txt Sun May 26 01:39:58 2013
@@ -8,47 +8,47 @@
 *** Test Cases ***
 Remove All
     [Setup]    Run Rebot and Set My Suite    --RemoveKeywords ALL    0
- Keyword Should Be Empty ${MY SUITE.setup} My Keyword ['Suite Setup'] + Keyword Should Be Empty ${MY SUITE.setup} My Keyword Suite Setup
     Keyword Should Contain Removal Message    ${MY SUITE.setup}
     ${tc1}    ${tc2} =    Set Variable    ${MY SUITE.tests}
     Length Should Be    ${tc1.keywords}    1
-    Keyword Should Be Empty    ${tc1.keywords[0]}    My Keyword    ['Pass']
+    Keyword Should Be Empty    ${tc1.keywords[0]}    My Keyword    Pass
     Length Should Be    ${tc2.keywords}    2
-    Keyword Should Be Empty    ${tc2.keywords[0]}    My Keyword    ['Fail']
- Keyword Should Be Empty ${tc2.keywords[1]} BuiltIn.Fail ['Expected failure']
+    Keyword Should Be Empty    ${tc2.keywords[0]}    My Keyword    Fail
+ Keyword Should Be Empty ${tc2.keywords[1]} BuiltIn.Fail Expected failure Keyword Should Contain Removal Message ${tc2.keywords[1]} Fails the test with the given message and optionally alters its tags.\n\n

 Remove Passed
     [Setup]    Run Rebot and Set My Suite    --removekeywords passed    0
- Keyword Should Not Be Empty ${MY SUITE.setup} My Keyword ['Suite Setup'] + Keyword Should Not Be Empty ${MY SUITE.setup} My Keyword Suite Setup
     ${tc1}    ${tc2} =    Set Variable    ${MY SUITE.tests}
     Length Should Be    ${tc1.keywords}    1
-    Keyword Should Be Empty    ${tc1.keywords[0]}    My Keyword    ['Pass']
+    Keyword Should Be Empty    ${tc1.keywords[0]}    My Keyword    Pass
     Keyword Should Contain Removal Message     ${tc1.keywords[0]}
     Length Should Be    ${tc2.keywords}    2
- Keyword Should Not Be Empty ${tc2.keywords[0]} My Keyword ['Fail'] - Keyword Should Not Be Empty ${tc2.keywords[1]} BuiltIn.Fail ['Expected failure']
+    Keyword Should Not Be Empty    ${tc2.keywords[0]}    My Keyword    Fail
+ Keyword Should Not Be Empty ${tc2.keywords[1]} BuiltIn.Fail Expected failure

 Keywords With Warnings Are Not Removed When Passed are Removed
     [Setup]    Run Rebot and Set My Suite    --removekeywords Passed    1
- Keyword Should Not Be Empty ${MY SUITE.setup} Warning in ['suite setup'] - Keyword Should Not Be Empty ${MY SUITE.teardown} Warning in ['suite teardown'] + Keyword Should Not Be Empty ${MY SUITE.setup} Warning in suite setup + Keyword Should Not Be Empty ${MY SUITE.teardown} Warning in suite teardown
     ${tc1}    ${tc2}=    Set Variable    ${MY SUITE.tests}
     Length Should Be    ${tc1.kws}    1
     Length Should Be    ${tc2.kws}    1
- Keyword Should Not Be Empty ${tc1.kws[0]} Warning in ['test case'] - Keyword Should Not Be Empty ${tc1.kws[0].kws[0]} BuiltIn.Log ['Warning in \${where}', 'WARN'] - Keyword Should Be Empty ${tc2.kws[0]} BuiltIn.Log ['No warnings here']
+    Keyword Should Not Be Empty    ${tc1.kws[0]}    Warning in    test case
+ Keyword Should Not Be Empty ${tc1.kws[0].kws[0]} BuiltIn.Log Warning in \${where} WARN + Keyword Should Be Empty ${tc2.kws[0]} BuiltIn.Log No warnings here

 Keywords With Warnings Are Removed When All are Removed
     [Setup]    Run Rebot and Set My Suite    --removekeywords All    1
- Keyword Should Be Empty ${MY SUITE.setup} Warning in ['suite setup'] - Keyword Should Be Empty ${MY SUITE.teardown} Warning in ['suite teardown'] + Keyword Should Be Empty ${MY SUITE.setup} Warning in suite setup + Keyword Should Be Empty ${MY SUITE.teardown} Warning in suite teardown
     ${tc1}    ${tc2}=    Set Variable    ${MY SUITE.tests}
     Length Should Be    ${tc1.kws}    1
     Length Should Be    ${tc2.kws}    1
-    Keyword Should Be Empty    ${tc1.kws[0]}    Warning in    ['test case']
- Keyword Should Be Empty ${tc2.kws[0]} BuiltIn.Log ['No warnings here']
+    Keyword Should Be Empty    ${tc1.kws[0]}    Warning in    test case
+ Keyword Should Be Empty ${tc2.kws[0]} BuiltIn.Log No warnings here

 *** Keywords ***
 Run Some Tests
=======================================
--- /atest/robot/cli/rebot/remove_keywords/remove_keywords_resource.txt Wed Sep 12 16:05:24 2012 +++ /atest/robot/cli/rebot/remove_keywords/remove_keywords_resource.txt Sun May 26 01:39:58 2013
@@ -6,20 +6,20 @@

 *** Keywords ***
 Keyword Should Be Empty
-    [Arguments]    ${kw}    ${name}    ${args}
-    Check Keyword Name And Args    ${kw}    ${name}    ${args}
+    [Arguments]    ${kw}    ${name}    @{args}
+    Check Keyword Name And Args    ${kw}    ${name}    @{args}
     Should Be Empty    ${kw.keywords}
     Should Be Empty    ${kw.messages}

 Keyword Should Not Be Empty
-    [Arguments]    ${kw}    ${name}    ${args}
-    Check Keyword Name And Args    ${kw}    ${name}    ${args}
+    [Arguments]    ${kw}    ${name}    @{args}
+    Check Keyword Name And Args    ${kw}    ${name}    @{args}
     ${num_keywords}=    Get Length    ${kw.keywords}
     ${num_messages}=    Get Length    ${kw.messages}
     Should Be True    ${num_keywords} + ${num_messages} > 0

 Check Keyword Name And Args
-    [Arguments]    ${kw}    ${name}    ${args}
+    [Arguments]    ${kw}    ${name}    @{args}
     Should Be Equal    ${kw.name}    ${name}
-    Should Be True    ${kw.args} == ${args}
+    Lists Should Be Equal    ${kw.args}    ${args}

=======================================
--- /atest/robot/keywords/repeating_keyword.txt Wed Apr 20 05:35:52 2011
+++ /atest/robot/keywords/repeating_keyword.txt Sun May 26 01:39:58 2013
@@ -14,10 +14,10 @@
     ${test} =  Check Test Case  Repeat With Arguments Doing Nothing
     Verify Deprecation Messages  ${test.kws[0].msgs[0]}  1 x
     Equals  ${test.kws[0].name}  1 x
-    Fail Unless  ${test.kws[0].args} == ['Comment', 'Nothing is done']
+    Fail Unless  ${test.kws[0].args} == ('Comment', 'Nothing is done')
     Verify Deprecation Messages  ${test.kws[1].msgs[0]}  42 X
     Equals  ${test.kws[1].name}  42 X
-    Fail Unless  ${test.kws[1].args} == ['Comment', 'Still', 'nothing']
+    Fail Unless  ${test.kws[1].args} == ('Comment', 'Still', 'nothing')

 Repeat Keyword Messages
     ${test} =  Check Test Case  Repeat With Messages
=======================================
--- /src/robot/model/keyword.py Wed May 22 15:27:57 2013
+++ /src/robot/model/keyword.py Sun May 26 01:39:58 2013
@@ -29,11 +29,11 @@
     keyword_class = None
     message_class = Message

- def __init__(self, name='', doc='', args=None, type='kw', timeout=None):
+    def __init__(self, name='', doc='', args=(), type='kw', timeout=None):
         self.parent = None
         self.name = name
         self.doc = doc
-        self.args = args or []
+        self.args = args
         self.type = type
         self.timeout = timeout
         self.messages = []
=======================================
--- /src/robot/result/keyword.py        Sat Jan  5 08:39:49 2013
+++ /src/robot/result/keyword.py        Sun May 26 01:39:58 2013
@@ -21,7 +21,7 @@
     __slots__ = ['status', 'starttime', 'endtime', 'message']
     message_class = Message

-    def __init__(self, name='', doc='', args=None, type='kw', timeout='',
+    def __init__(self, name='', doc='', args=(), type='kw', timeout='',
                  status='FAIL', starttime=None, endtime=None):
         """Results of a single keyword.

=======================================
--- /src/robot/result/xmlelementhandlers.py     Fri May 24 06:03:27 2013
+++ /src/robot/result/xmlelementhandlers.py     Sun May 26 01:39:58 2013
@@ -214,7 +214,7 @@
     tag = 'arg'

     def end(self, elem, result):
-        result.args.append(elem.text or '')
+        result.args += (elem.text or '',)


 class ErrorsHandler(_Handler):
=======================================
--- /utest/result/test_resultbuilder.py Thu May 23 05:52:43 2013
+++ /utest/result/test_resultbuilder.py Sun May 26 01:39:58 2013
@@ -56,21 +56,22 @@
     def test_keyword_is_built(self):
         assert_equals(self._keyword.name, 'BuiltIn.Log')
assert_equals(self._keyword.doc, 'Logs the given message with the given level.')
-        assert_equals(self._keyword.timeout, None)
-        assert_equals(self._keyword.args, ['Test 1'])
+        assert_equals(self._keyword.args, ('Test 1',))
         assert_equals(self._keyword.status, 'PASS')
         assert_equals(self._keyword.starttime, '20111024 13:41:20.926')
         assert_equals(self._keyword.endtime, '20111024 13:41:20.928')
+        assert_equals(self._keyword.timeout, None)
         assert_equals(len(self._keyword.keywords), 0)
         assert_equals(len(self._keyword.messages), 1)

     def test_user_keyword_is_built(self):
         assert_equals(self._user_keyword.name, 'logs on trace')
         assert_equals(self._user_keyword.doc, '')
-        assert_equals(self._user_keyword.args, [])
+        assert_equals(self._user_keyword.args, ())
         assert_equals(self._user_keyword.status, 'PASS')
assert_equals(self._user_keyword.starttime, '20111024 13:41:20.930')
         assert_equals(self._user_keyword.endtime, '20111024 13:41:20.933')
+        assert_equals(self._user_keyword.timeout, None)
         assert_equals(len(self._user_keyword.messages), 0)
         assert_equals(len(self._user_keyword.keywords), 1)

--

--- 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