2 new revisions:

Revision: ae4f714952b3
Author:   Pekka Klärck
Date:     Wed Dec 14 02:18:23 2011
Log:      fixed xunit tests on windows
http://code.google.com/p/robotframework/source/detail?r=ae4f714952b3

Revision: e987a1693e72
Author:   Pekka Klärck
Date:     Wed Dec 14 02:20:42 2011
Log:      Uniform API to OutputWriter and XUnitWriter
http://code.google.com/p/robotframework/source/detail?r=e987a1693e72

==============================================================================
Revision: ae4f714952b3
Author:   Pekka Klärck
Date:     Wed Dec 14 02:18:23 2011
Log:      fixed xunit tests on windows
http://code.google.com/p/robotframework/source/detail?r=ae4f714952b3

Modified:
 /atest/robot/output/xunit.txt
 /atest/robot/rebot/xunit.txt

=======================================
--- /atest/robot/output/xunit.txt       Tue Dec 13 14:47:09 2011
+++ /atest/robot/output/xunit.txt       Wed Dec 14 02:18:23 2011
@@ -6,7 +6,7 @@

 *** Variables ***
 ${TESTDATA}  misc/pass_and_fail.html
-${INVALID}   ${TEMPDIR}${/}ïnvälïd-ẍünïẗ.xml
+${INVALID}   ${TEMPDIR}${/}ïnvälïd-xünït.xml

 *** Test Cases ***
 No XUnit Option Given
@@ -29,6 +29,8 @@
     Run Tests  --XUnitFile ${INVALID} -l log.html  ${TESTDATA}
     File Should Not Exist  ${INVALID}
     File Should Exist  ${OUTDIR}/log.html
+    ${dir}  ${base} =  Split Path  ${INVALID}
+    ${path} =  Regexp Escape  ${INVALID}
     Check Stderr Matches Regexp
- ... \\[ ERROR \\] Opening XUnit result file '${INVALID}' failed: .*directory.*
-
+    ...  \\[ ERROR \\] Opening XUnit result file '${path}' failed: .*
+
=======================================
--- /atest/robot/rebot/xunit.txt        Tue Dec 13 14:09:27 2011
+++ /atest/robot/rebot/xunit.txt        Wed Dec 14 02:18:23 2011
@@ -11,7 +11,7 @@
 ${TESTDATA_SUITES}  misc${/}suites
 ${MYOUTDIR}         ${TEMPDIR}${/}robot-test-xunit
 ${INPUT FILE}       ${TEMPDIR}${/}robot-test-xunit-file.xml
-${INVALID}          ${TEMPDIR}${/}ïnvälïd-ẍünïẗ.xml
+${INVALID}          ${TEMPDIR}${/}ïnvälïd-xünït.xml


 *** Test Cases ***
@@ -36,8 +36,9 @@
     Run Rebot  -x ${INVALID} -l log.html  ${INPUT FILE}
     File Should Not Exist  ${INVALID}
     File Should Exist  ${OUTDIR}/log.html
+    ${path} =  Regexp Escape  ${INVALID}
     Check Stderr Matches Regexp
- ... \\[ ERROR \\] Opening XUnit result file '${INVALID}' failed: .*directory.*
+    ...  \\[ ERROR \\] Opening XUnit result file '${path}' failed: .*

 *** Keywords ***
 Create Input File

==============================================================================
Revision: e987a1693e72
Author:   Pekka Klärck
Date:     Wed Dec 14 02:20:42 2011
Log:      Uniform API to OutputWriter and XUnitWriter
http://code.google.com/p/robotframework/source/detail?r=e987a1693e72

Modified:
 /src/robot/reporting/builders.py
 /src/robot/reporting/xunitwriter.py
 /src/robot/result/outputwriter.py
 /utest/result/test_resultserializer.py

=======================================
--- /src/robot/reporting/builders.py    Wed Dec 14 01:46:23 2011
+++ /src/robot/reporting/builders.py    Wed Dec 14 02:20:42 2011
@@ -33,10 +33,11 @@

     def build(self, path):
         try:
-            OutputWriter(self._model).write_to(path)
+            writer = OutputWriter(path)
         except DataError, err:
             LOGGER.error(unicode(err))
         else:
+            self._model.visit(writer)
             LOGGER.output_file('Output', path)


@@ -53,7 +54,6 @@
                          % (path, err.strerror))
         else:
             self._model.visit(writer)
-            writer.close()
             LOGGER.output_file('XUnit', path)


=======================================
--- /src/robot/reporting/xunitwriter.py Thu Dec  1 04:53:30 2011
+++ /src/robot/reporting/xunitwriter.py Wed Dec 14 02:20:42 2011
@@ -28,9 +28,6 @@
         self._root_suite = None
         self._detail_serializer = _NopSerializer()

-    def close(self):
-        self._writer.close()
-
     def start_suite(self, suite):
         if self._root_suite:
             return
@@ -71,6 +68,9 @@
     def visit_message(self, msg):
         self._detail_serializer.message(msg)

+    def end_result(self, result):
+        self._writer.close()
+

 class _FailedTestSerializer:
     """Specific policy to serialize a failed test case details"""
=======================================
--- /src/robot/result/outputwriter.py   Wed Dec 14 01:46:23 2011
+++ /src/robot/result/outputwriter.py   Wed Dec 14 02:20:42 2011
@@ -17,16 +17,12 @@

 # TODO: Unify XmlLogger and ResultVisitor APIs.
 # Perhaps XmlLogger could be ResultVisitor.
-# TODO: Use delegation instead of multi-inheritance
+

 class OutputWriter(XmlLogger, ResultVisitor):

-    def __init__(self, model):
-        self._model = model
-
-    def write_to(self, path):
-        XmlLogger.__init__(self, path, generator='Rebot')
-        self._model.visit(self)
+    def __init__(self, output):
+        XmlLogger.__init__(self, output, generator='Rebot')

     def start_message(self, msg):
         self._write_message(msg)
=======================================
--- /utest/result/test_resultserializer.py      Wed Dec 14 01:46:23 2011
+++ /utest/result/test_resultserializer.py      Wed Dec 14 02:20:42 2011
@@ -69,9 +69,9 @@
 class TestResultSerializer(unittest.TestCase):

     def test_single_result_serialization(self):
-        writer = TestableOutputWriter(ResultFromXml(GOLDEN_XML))
         output = StringIO()
-        writer.write_to(output)
+        writer = TestableOutputWriter(output)
+        ResultFromXml(GOLDEN_XML).visit(writer)
         self._assert_xml_content(self._xml_lines(output.getvalue()),
                                  self._xml_lines(GOLDEN_XML))

@@ -84,9 +84,9 @@
assert_equals(act, exp.strip(), 'Different values on line %d' % index)

     def test_combining_results(self):
- writer = TestableOutputWriter(ResultFromXml(GOLDEN_XML, GOLDEN_XML))
         output = StringIO()
-        writer.write_to(output)
+        writer = TestableOutputWriter(output)
+        ResultFromXml(GOLDEN_XML, GOLDEN_XML).visit(writer)
         self._assert_xml_content(self._xml_lines(output.getvalue()),
                                  self._xml_lines(GOLDEN_XML_TWICE))

Reply via email to