4 new revisions:

Revision: 5d07663846dd
Author:   Pekka Klärck
Date:     Wed Jan  4 02:12:51 2012
Log: Listeners: Added suite source to attributes passed to start_suite and ...
http://code.google.com/p/robotframework/source/detail?r=5d07663846dd

Revision: ca05d20c563d
Author:   Pekka Klärck
Date:     Wed Jan  4 02:13:11 2012
Log:      recompile
http://code.google.com/p/robotframework/source/detail?r=ca05d20c563d

Revision: 8fdcd39fab13
Author:   Pekka Klärck
Date:     Wed Jan  4 02:14:54 2012
Log:      Documented passing suite source to listeners....
http://code.google.com/p/robotframework/source/detail?r=8fdcd39fab13

Revision: ba2fd435b05c
Author:   Pekka Klärck
Date:     Wed Jan  4 02:49:59 2012
Log:      More tests and small fix for passing suite source to listeners....
http://code.google.com/p/robotframework/source/detail?r=ba2fd435b05c

==============================================================================
Revision: 5d07663846dd
Author:   Pekka Klärck
Date:     Wed Jan  4 02:12:51 2012
Log: Listeners: Added suite source to attributes passed to start_suite and end_suite.

This is a patch by imranoftherings. Thanks!

Update issue 1015
Status: Started
Owner: pekka.klarck
Code and test changes applied.
http://code.google.com/p/robotframework/source/detail?r=5d07663846dd

Modified:
 /atest/robot/output/listener_interface/listener_methods.txt
 /atest/testresources/listeners/JavaAttributeVerifyingListener.java
 /atest/testresources/listeners/attributeverifyinglistener.py
 /src/robot/output/listeners.py

=======================================
--- /atest/robot/output/listener_interface/listener_methods.txt Fri Sep 23 02:54:04 2011 +++ /atest/robot/output/listener_interface/listener_methods.txt Wed Jan 4 02:12:51 2012
@@ -56,14 +56,14 @@
     ${status} =  Log File  ${TEMPDIR}/${ATTR_TYPE_FILE}
     Check Stderr Does Not Contain  attributeverifyinglistener
     Should Not Contain  ${status}  FAILED
-    Should Contain X Times  ${status}  PASSED  158
+    Should Contain X Times  ${status}  PASSED  160

 Correct Attributes To Java Listener Methods
     [Tags]  jybot
     ${status} =  Log File  ${JAVATEMPDIR}/${JAVA_ATTR_TYPE_FILE}
     Check Stderr Does Not Contain  JavaAttributeVerifyingListener
     Should Not Contain  ${status}  FAILED
-    Should Contain X Times  ${status}  PASSED  158
+    Should Contain X Times  ${status}  PASSED  160

 Suite And Test Counts
     Run Tests  --listener listeners.SuiteAndTestCounts  misc/suites/sub*
=======================================
--- /atest/testresources/listeners/JavaAttributeVerifyingListener.java Fri Jul 22 01:51:13 2011 +++ /atest/testresources/listeners/JavaAttributeVerifyingListener.java Wed Jan 4 02:12:51 2012
@@ -34,12 +34,12 @@

     public void startSuite(String name, Map attrs) {
         verifyAttributes("START SUITE", attrs,
- new String[] {"doc", "starttime", "longname", "metadata", "tests", "suites", "totaltests"}); + new String[] {"doc", "starttime", "longname", "source", "metadata", "tests", "suites", "totaltests"});
     }

     public void endSuite(String name, Map attrs) {
         verifyAttributes("END SUITE", attrs,
- new String[] {"doc", "starttime", "longname", "metadata", "endtime", "elapsedtime", "status", "message", "statistics"}); + new String[] {"doc", "starttime", "longname", "source", "metadata", "endtime", "elapsedtime", "status", "message", "statistics"});
     }

     public void startTest(String name, Map attrs) {
=======================================
--- /atest/testresources/listeners/attributeverifyinglistener.py Fri Jul 22 01:51:13 2011 +++ /atest/testresources/listeners/attributeverifyinglistener.py Wed Jan 4 02:12:51 2012
@@ -13,11 +13,11 @@

 def start_suite(name, attrs):
     _verify_attrs('START SUITE', attrs,
- START_ATTRS + 'longname metadata tests suites totaltests') + START_ATTRS + 'longname metadata source tests suites totaltests')

 def end_suite(name, attrs):
     _verify_attrs('END SUITE', attrs,
-                  END_ATTRS + 'longname metadata statistics message')
+ END_ATTRS + 'longname metadata source statistics message')

 def start_test(name, attrs):
     _verify_attrs('START TEST', attrs,
=======================================
--- /src/robot/output/listeners.py      Tue Jan  3 04:26:44 2012
+++ /src/robot/output/listeners.py      Wed Jan  4 02:12:51 2012
@@ -83,7 +83,8 @@
                 attrs = self._get_start_attrs(suite, 'metadata')
                 attrs.update({'tests' : [t.name for t in suite.tests],
                               'suites': [s.name for s in suite.suites],
-                              'totaltests': suite.get_test_count()})
+                              'totaltests': suite.get_test_count(),
+                              'source': suite.source})
                 li.call_method(li.start_suite, suite.name, attrs)

     def end_suite(self, suite):
@@ -94,6 +95,7 @@
             else:
                 attrs = self._get_end_attrs(suite, 'metadata')
                 attrs['statistics'] = suite.get_stat_message()
+                attrs['source'] = suite.source
                 li.call_method(li.end_suite, suite.name, attrs)

     def start_test(self, test):

==============================================================================
Revision: ca05d20c563d
Author:   Pekka Klärck
Date:     Wed Jan  4 02:13:11 2012
Log:      recompile
http://code.google.com/p/robotframework/source/detail?r=ca05d20c563d

Modified:
 /atest/testresources/listeners/JavaAttributeVerifyingListener.class

=======================================
--- /atest/testresources/listeners/JavaAttributeVerifyingListener.class Fri Jul 22 02:02:53 2011 +++ /atest/testresources/listeners/JavaAttributeVerifyingListener.class Wed Jan 4 02:13:11 2012
@@ -43,10 +43,11 @@
 "5RSUOP)
 *»Y*·µ±Q
 !VWPM1*,½YSYSYSYSYSYSY
+SY
 S·
 ±Q
 $0&XWPY=*
-,     ½YSYSYSYSYSY SY!SY"SY#S·
+½YSYSYSYSYSY SY!SY"SY#SY     $S·
 ±Q
 )<+YWPG+*$,½YSYSYSY%SY&SY'S·
 ±Q

==============================================================================
Revision: 8fdcd39fab13
Author:   Pekka Klärck
Date:     Wed Jan  4 02:14:54 2012
Log:      Documented passing suite source to listeners.

Based on patch by imranoftherings.

Update issue 1015
User Guide documentation applied with some changes.
http://code.google.com/p/robotframework/source/detail?r=8fdcd39fab13

Modified:
 /doc/userguide/src/ExtendingRobotFramework/ListenerInterface.txt

=======================================
--- /doc/userguide/src/ExtendingRobotFramework/ListenerInterface.txt Sun Sep 25 11:30:46 2011 +++ /doc/userguide/src/ExtendingRobotFramework/ListenerInterface.txt Wed Jan 4 02:14:54 2012
@@ -93,6 +93,8 @@
| | | * doc: test suite documentation | | | | * metadata: dictionary/map containing `free test | | | | suite metadata`_ (new in 2.5) | + | | | * source: absolute path of the file/directory | + | | | test suite was created from (new in 2.7) | | | | * suites: names of suites directly in this suite | | | | as a list of strings (new in 2.5) | | | | * tests: names of tests directly in this suite |
@@ -108,6 +110,8 @@
| | | * doc: test suite documentation | | | | * metadata: dictionary/map containing `free test | | | | suite metadata`_ (new in 2.6) | + | | | * source: absolute path of the file/directory | + | | | test suite was created from (new in 2.7) | | | | * starttime: execution start time | | | | * endtime: execution end time | | | | * elapsedtime: execution time in milliseconds |

==============================================================================
Revision: ba2fd435b05c
Author:   Pekka Klärck
Date:     Wed Jan  4 02:49:59 2012
Log:      More tests and small fix for passing suite source to listeners.

Update issue 1015
Status: Done
1) Added tests to verify that the source is correct.

2) When running multiple suites at once, the top level suite has no
source. I changed the source passed to listeners to be en empty string
instead of None/null in this special case. Not sure should this have
been also documented in the User Guide.
http://code.google.com/p/robotframework/source/detail?r=ba2fd435b05c

Modified:
 /atest/robot/output/listener_interface/listener_methods.txt
 /atest/testresources/listeners/listeners.py
 /src/robot/output/listeners.py

=======================================
--- /atest/robot/output/listener_interface/listener_methods.txt Wed Jan 4 02:12:51 2012 +++ /atest/robot/output/listener_interface/listener_methods.txt Wed Jan 4 02:49:59 2012
@@ -69,6 +69,10 @@
     Run Tests  --listener listeners.SuiteAndTestCounts  misc/suites/sub*
     Stderr Should Be Empty

+Suite Source
+ Run Tests --listener listeners.SuiteSource --name Root misc/suites/subsuites misc/pass_and_fail.html
+    Stderr Should Be Empty
+
 Keyword Type
Run Tests --listener listeners.KeywordType misc/setups_and_teardowns.txt
     Stderr Should Be Empty
=======================================
--- /atest/testresources/listeners/listeners.py Fri Sep 23 02:54:04 2011
+++ /atest/testresources/listeners/listeners.py Wed Jan  4 02:49:59 2012
@@ -86,3 +86,33 @@

     def _run_keyword(self, arg):
         BuiltIn().run_keyword('Log', arg)
+
+
+class SuiteSource(object):
+    ROBOT_LISTENER_API_VERSION = '2'
+
+    def __init__(self):
+        self._started = 0
+        self._ended = 0
+
+    def start_suite(self, name, attrs):
+        self._started += 1
+        self._test_source(name, attrs['source'])
+
+    def end_suite(self, name, attrs):
+        self._ended += 1
+        self._test_source(name, attrs['source'])
+
+    def _test_source(self, suite, source):
+        default = os.path.isfile
+        verifier = {'Root': lambda source: source == '',
+                    'Subsuites': os.path.isdir}.get(suite, default)
+        if (source and not os.path.isabs(source)) or not verifier(source):
+            raise AssertionError("Suite '%s' has wrong source '%s'"
+                                 % (suite, source, verifier))
+
+    def close(self):
+        if not (self._started == self._ended == 5):
+ raise AssertionError("Wrong number of started (%d) or ended (%d) "
+                                 "suites. Expected 5."
+                                 % (self._started, self._ended))
=======================================
--- /src/robot/output/listeners.py      Wed Jan  4 02:12:51 2012
+++ /src/robot/output/listeners.py      Wed Jan  4 02:49:59 2012
@@ -84,7 +84,7 @@
                 attrs.update({'tests' : [t.name for t in suite.tests],
                               'suites': [s.name for s in suite.suites],
                               'totaltests': suite.get_test_count(),
-                              'source': suite.source})
+                              'source': suite.source or ''})
                 li.call_method(li.start_suite, suite.name, attrs)

     def end_suite(self, suite):
@@ -94,8 +94,8 @@
                                suite.get_full_message())
             else:
                 attrs = self._get_end_attrs(suite, 'metadata')
-                attrs['statistics'] = suite.get_stat_message()
-                attrs['source'] = suite.source
+                attrs.update({'statistics': suite.get_stat_message(),
+                              'source': suite.source or ''})
                 li.call_method(li.end_suite, suite.name, attrs)

     def start_test(self, test):

Reply via email to