4 new revisions:

Revision: 9979dbe422e3
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 04:32:39 2011
Log:      Removed unit tests related to splitting
http://code.google.com/p/robotframework/source/detail?r=9979dbe422e3

Revision: 92f1f24a2c74
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 04:56:54 2011
Log:      removed code related to splitting
http://code.google.com/p/robotframework/source/detail?r=92f1f24a2c74

Revision: 9d88d2b323e4
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 05:36:38 2011
Log:      testoutput: extracted classes for log and report building
http://code.google.com/p/robotframework/source/detail?r=9d88d2b323e4

Revision: 01a83e97403b
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 06:41:36 2011
Log:      Automated merge with https://robotframework.googlecode.com/hg/
http://code.google.com/p/robotframework/source/detail?r=01a83e97403b

==============================================================================
Revision: 9979dbe422e3
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 04:32:39 2011
Log:      Removed unit tests related to splitting
http://code.google.com/p/robotframework/source/detail?r=9979dbe422e3

Modified:
 /utest/common/test_baseobjects.py

=======================================
--- /utest/common/test_baseobjects.py   Tue Feb  1 01:30:26 2011
+++ /utest/common/test_baseobjects.py   Wed Jun 15 04:32:39 2011
@@ -1,20 +1,19 @@
 import unittest
-import sys

 from robot.utils.asserts import assert_equals, assert_raises_with_msg,\
     assert_true, assert_false
 from robot import utils
 from robot.errors import DataError
-
 from robot.common.model import BaseTestSuite, BaseTestCase, _Critical

+
 def _get_suite():
     suite = BaseTestSuite('Root')
suite.suites = [ BaseTestSuite('Sub1', parent=suite), BaseTestSuite('Sub2', parent=suite) ] - suite.suites[0].suites = [ BaseTestSuite('Sub11', parent=suite.suites[0]), + suite.suites[0].suites = [ BaseTestSuite('Sub11', parent=suite.suites[0]),
                               BaseTestSuite('Sub', parent=suite.suites[0])]
     suite.suites[0].suites[0].tests \
-            = [ BaseTestCase('T11', suite.suites[0].suites[0]),
+            = [ BaseTestCase('T11', suite.suites[0].suites[0]),
                BaseTestCase('T12', suite.suites[0].suites[0]) ]
     suite.suites[0].suites[0].suites \
             = [ BaseTestSuite('Sub', parent=suite.suites[0].suites[0]) ]
@@ -24,11 +23,12 @@
     suite.suites[1].tests = [ BaseTestCase('T21', suite.suites[1]) ]
     return suite

+
 class TestGetLongName(unittest.TestCase):
-
+
     def setUp(self):
         self.suite = _get_suite()
-
+
     def test_get_long_name_for_root_suite(self):
         assert_equals(self.suite.get_long_name(), 'Root')

@@ -36,62 +36,33 @@
         assert_equals(self.suite.suites[0].get_long_name(), 'Root.Sub1')

     def test_get_long_name_for_sub_sub_suite(self):
-        assert_equals(self.suite.suites[0].suites[1].get_long_name(),
+        assert_equals(self.suite.suites[0].suites[1].get_long_name(),
                       'Root.Sub1.Sub')

     def test_get_long_name_for_test(self):
- assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(), + assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(),
                       'Root.Sub1.Sub11.T11')

     def test_get_long_name_for_test_with_non_default_separator(self):
- assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(separator='|'), + assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(separator='|'),
                       'Root|Sub1|Sub11|T11')

     def test_get_long_name_for_sub_suite_with_parts(self):
-        assert_equals(self.suite.suites[0].get_long_name(separator=None),
+        assert_equals(self.suite.suites[0].get_long_name(separator=None),
                       ['Root', 'Sub1'])

     def test_get_long_name_for_test_with_parts(self):
- assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(separator=None), + assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(separator=None),
                       ['Root', 'Sub1', 'Sub11', 'T11'])

-    def test_get_long_name_for_sub_suite_with_split_level_smaller(self):
-        assert_equals(self.suite.suites[0].get_long_name(split_level=1),
-                      'Sub1')
-
-    def test_get_long_name_for_sub_suite_with_split_level_same(self):
-        assert_equals(self.suite.suites[0].get_long_name(split_level=2),
-                      'Root.Sub1')
-
-    def test_get_long_name_for_sub_suite_with_split_level_larger(self):
-        assert_equals(self.suite.suites[0].get_long_name(split_level=3),
-                      'Root.Sub1')
-
-    def test_get_long_name_for_test_with_split_level_smaller(self):
- assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(split_level=2),
-                      'Sub11.T11')
-
- def test_get_long_name_for_test_with_split_level_at_parent_suite_level(self): - assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(split_level=3),
-                      'Root.Sub1.Sub11.T11')
-
-    def test_get_long_name_for_test_with_split_level_same(self):
- assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(split_level=4),
-                      'Root.Sub1.Sub11.T11')
-
-    def test_get_long_name_for_test_with_split_level_larger(self):
- assert_equals(self.suite.suites[0].suites[0].tests[0].get_long_name(split_level=5),
-                      'Root.Sub1.Sub11.T11')
-

 class TestFilterByNames(unittest.TestCase):
-
-
+
     def test_with_suites(self):
         for names, count in [ (['Root'], 5),
                               (['Sub1'], 4),
                               (['Sub 11'], 3),
-                              (['s u b 2'], 1),
+                              (['s u b 2'], 1),
                               (['Sub?'], 5),
                               (['Sub 1*'], 4),
                               (['ROOT','Sub1'], 5),
@@ -105,15 +76,15 @@
     def test_with_suites_no_matches(self):
         suite = _get_suite()
         err =  "Suite 'Root' contains no test suites named '%s'."
-        assert_raises_with_msg(DataError, err % ('nonex'),
+        assert_raises_with_msg(DataError, err % ('nonex'),
                                suite.filter_by_names, ['nonex'], [])
-        assert_raises_with_msg(DataError, err % ('b1.Sub'),
+        assert_raises_with_msg(DataError, err % ('b1.Sub'),
                                suite.filter_by_names, ['b1.Sub'], [])

     def test_with_tests(self):
         for names, count in [ (['T11'], 1),
                               (['?12'], 1),
-                              (['t 2  1'], 1),
+                              (['t 2  1'], 1),
                               (['t*'], 5),
                               (['??1'], 2),
                               (['T11','T12'], 2),
@@ -131,7 +102,7 @@

     def test_with_suites_and_tests(self):
         for suites, tests, count in [ (['Root'], ['T11'], 1),
-                                      (['Sub1'], ['t 1  2'], 1),
+                                      (['Sub1'], ['t 1  2'], 1),
                                       (['sub11'], ['t11','nonex'], 1),
                                       (['sub1'], ['t11','t2.1'], 1),
                                       (['sub?'], ['t11','t21'], 2),
@@ -146,51 +117,51 @@
         for suites, tests in [ (['Root'], ['nonex']),
                                (['Nonex'], ['T1.1']),
                                (['Sub2'], ['T1.1']), ]:
-            msg = ("Suite 'Root' contains no test cases %s in suites %s."
+            msg = ("Suite 'Root' contains no test cases %s in suites %s."
                    % (utils.seq2str(tests, lastsep=' or '),
                       utils.seq2str(suites, lastsep=' or ')))
assert_raises_with_msg(DataError, msg, suite.filter_by_names, suites, tests)


 class TestSetCriticality(unittest.TestCase):
-
+
     def _test(self, crit, noncrit, exp):
         test = BaseTestCase('Name', parent=None)
         critical = _Critical()
         critical.set(crit, noncrit)
         test.tags = ['tag1', 'tag2', 'tag3']
         test.set_criticality(critical)
-        assert_equals(test.critical, exp)
-
+        assert_equals(test.critical, exp)
+
     def test_no_crit_nor_noncrit(self):
         self._test([], [], 'yes')
-
+
     def test_non_matching_crit(self):
         self._test(['no','match'], [], 'no')
-
+
     def test_non_matching_noncrit(self):
         self._test([], ['nomatch'], 'yes')
-
+
     def test_non_matching_crit_and_noncrit(self):
         self._test(['no'], ['match','here'], 'no')
-
+
     def test_matching_crit(self):
         self._test(['tag1','match'], [], 'yes')
-
+
     def test_matching_noncrit(self):
         self._test([], ['tag1','tag2'], 'no')
-
+
     def test_matching_crit_and_noncrit(self):
         self._test(['tag1'], ['yyy','tag2','xxx'], 'no')
-
+
     def test_crit_is_pattern(self):
         self._test(['*1'], [], 'yes')
         self._test(['*1'], ['tag2'], 'no')
-
+
     def test_non_crit_is_pattern(self):
         self._test([], ['tag?'], 'no')
         self._test(['tag1','tagx'], ['????'], 'no')
-
+
     def test_crit_and_noncrit_are_patterns(self):
         self._test(['*1'], ['tag?'], 'no')
         self._test(['?a?3'], ['nomatch-*'], 'yes')
@@ -270,7 +241,7 @@
assert_true(self._tags123.is_included([], ['tag', 'excl', 'not', 'matching']))

     def test_invalid(self):
-        for invalid in [ 'NOT', 'NOTNOT', 'xNOTNOTy', 'NOTa', 'bNOT',
+        for invalid in [ 'NOT', 'NOTNOT', 'xNOTNOTy', 'NOTa', 'bNOT',
                          'NOTaNOTb', 'aNOTbNOT' ]:
             assert_false(self._tag1.is_included([invalid], []))
             assert_true(self._tag1.is_included(['tag1'], [invalid]))

==============================================================================
Revision: 92f1f24a2c74
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 04:56:54 2011
Log:      removed code related to splitting
http://code.google.com/p/robotframework/source/detail?r=92f1f24a2c74

Modified:
 /src/robot/__init__.py
 /src/robot/serializing/__init__.py
 /src/robot/serializing/testoutput.py

=======================================
--- /src/robot/__init__.py      Wed Jun 15 04:29:13 2011
+++ /src/robot/__init__.py      Wed Jun 15 04:56:54 2011
@@ -14,7 +14,6 @@

 import sys
 import os
-from robot.serializing.testoutput import Reporter

 if __name__ == '__main__':
     sys.stderr.write("Use 'runner' or 'rebot' for executing.\n")
@@ -45,7 +44,7 @@
 from output import Output, LOGGER, pyloggingconf
 from conf import RobotSettings, RebotSettings
 from running import TestSuite, STOP_SIGNAL_MONITOR
-from serializing import RobotTestOutput, RebotTestOutput
+from robot.serializing.testoutput import Reporter
 from errors import (DataError, Information, INFO_PRINTED, DATA_ERROR,
                     STOPPED_BY_USER, FRAMEWORK_ERROR)
 from variables import init_global_variables
=======================================
--- /src/robot/serializing/__init__.py  Wed Jun 15 04:01:03 2011
+++ /src/robot/serializing/__init__.py  Wed Jun 15 04:56:54 2011
@@ -13,5 +13,5 @@
 #  limitations under the License.


-from testoutput import RobotTestOutput, RebotTestOutput
+from testoutput import RobotTestOutput
 from templating import Template, Namespace
=======================================
--- /src/robot/serializing/testoutput.py        Wed Jun 15 04:29:44 2011
+++ /src/robot/serializing/testoutput.py        Wed Jun 15 04:56:54 2011
@@ -58,6 +58,7 @@
     def _resolve_background_colors(self):
         color_str = self._settings['ReportBackground']
         if color_str and color_str.count(':') not in [1, 2]:
+            LOGGER.error("Invalid background color '%s'." % color_str)
             color_str = None
         if not color_str:
             color_str = '#99FF66:#FF3333'
@@ -72,7 +73,6 @@
             serialize_log(data_model, log_path)
             LOGGER.output_file('Log', log_path)

-
     def _get_log_settings(self):
         return {
             'title': self._settings['ReportTitle'],
@@ -123,8 +123,6 @@
         return value if value != 'NONE' else None


-
-# TODO: Most (all?) of this class is dead code
 class RobotTestOutput:

     def __init__(self, suite, exec_errors, settings=None):
@@ -139,18 +137,6 @@
         self.statistics = Statistics(suite, *params)
         self._generator = 'Robot'

-    def serialize(self, settings, generator='Robot', output=None):
-        self._generator = generator
-        self.serialize_output(settings['Output'])
- self.serialize_summary(settings['Summary'], settings['SummaryTitle'],
-                               settings['ReportBackground'])
-        datamodel = jsparser.create_datamodel_from(output)
- serialize_report(datamodel, settings['Report'], settings['ReportTitle'], settings['Log'])
-        LOGGER.output_file('Report', settings['Report'])
-        serialize_log(datamodel, settings['Log'], settings['LogTitle'])
-        LOGGER.output_file('Log', settings['Log'])
-        self.serialize_xunit(settings['XUnitFile'])
-
     def serialize_output(self, path, log=True):
         if path == 'NONE':
             return
@@ -172,162 +158,3 @@
             serializer.close()
         LOGGER.output_file('XUnit', path)

-    def serialize_summary(self, path, title=None, background=None):
-        outfile = self._get_outfile(path, 'summary')
-        if not outfile:
-            return
-        self._use_template(outfile, templates.REPORT,
-                           title or '%s Summary Report' % self.suite.name,
-                           self._get_background_color(background))
-        self.statistics.serialize(SummaryStatSerializer(outfile))
-        outfile.write('</body>\n</html>\n')
-        outfile.close()
-        LOGGER.output_file('Summary', path)
-
-    def _get_background_color(self, colors):
-        all_passed, critical_passed, failures \
-                = self._resolve_background_colors(colors)
-        if self.suite.all_stats:
-            return all_passed
-        if self.suite.critical_stats:
-            return critical_passed
-        return failures
-
-    def _resolve_background_colors(self, color_str):
-        if color_str and color_str.count(':') not in [1, 2]:
-            LOGGER.error("Invalid background color '%s'." % color_str)
-            color_str = None
-        if not color_str:
-            color_str = '#99FF66:#FF3333'
-        colors = color_str.split(':', 2)
- return colors if len(colors) == 3 else [colors[0], colors[0], colors[1]]
-
-    def serialize_report(self, path, title=None, background=None,
-                         logpath=None, split=-1):
-        outfile = self._get_outfile(path, 'report')
-        if not outfile:
-            return
-        self._use_template(outfile, templates.REPORT,
-                           title or '%s Test Report' % self.suite.name,
-                           self._get_background_color(background))
-        self.statistics.serialize(ReportStatSerializer(outfile))
-        logpath = logpath if logpath != 'NONE' else None
-        if split > 0 and logpath:
- self.suite.serialize(SplitReportSerializer(outfile, logpath, split))
-        else:
-            self.suite.serialize(ReportSerializer(outfile, logpath))
-        self.statistics.tags.serialize(TagDetailsSerializer(outfile))
-        outfile.write('</body>\n</html>\n')
-        outfile.close()
-        LOGGER.output_file('Report', path)
-
-    def serialize_log(self, path, title=None, split=-1):
-        outfile = self._get_outfile(path, 'log')
-        if not outfile:
-            return
-        self._use_template(outfile, templates.LOG,
-                           title or '%s Test Log' % self.suite.name)
-        if split > 0:
-            self._serialize_split_log(outfile, split)
-        else:
-            self._serialize_log(outfile)
-        outfile.write('</body>\n</html>\n')
-        outfile.close()
-        LOGGER.output_file('Log', path)
-
-    def _serialize_log(self, outfile):
-        self.statistics.serialize(LogStatSerializer(outfile))
-        self.exec_errors.serialize(ErrorSerializer(outfile))
-        self.suite.serialize(LogSerializer(outfile))
-
-    def _serialize_split_log(self, outfile, level):
-        self.statistics.serialize(SplitLogStatSerializer(outfile, level))
-        self.exec_errors.serialize(ErrorSerializer(outfile))
-        self.suite.serialize(SplitLogSerializer(outfile, level))
-        self._create_split_sub_logs(self.suite, level)
-
-    def _create_split_sub_logs(self, suite, level):
-        # Overridden by RebotTestOutput
-        pass
-
-    def _use_template(self, outfile, template, title, background=None):
-        ttuple = time.localtime()
- str_time = utils.format_time(ttuple, daytimesep='&nbsp;', gmtsep='&nbsp;')
-        int_time = long(time.mktime(ttuple))
-        elapsed_time = utils.elapsed_time_to_string(self.suite.elapsedtime)
-        namespace = Namespace(gentime_str=str_time,
-                              gentime_int=int_time,
-                              elapsed_time=elapsed_time,
-                              version=get_full_version(self._generator),
-                              suite=self.suite,
-                              title=title,
-                              background=background)
-        Template(template=template).generate(namespace, outfile)
-
-    def _get_outfile(self, outpath, outtype):
-        if outpath != 'NONE':
-            try:
-                return open(outpath, 'wb')
-            except:
-                LOGGER.error("Opening %s file '%s' for writing failed: %s"
- % (outtype, outpath, utils.get_error_message()))
-        return None
-
-
-class RebotTestOutput(RobotTestOutput):
-
-    def __init__(self, datasources, settings):
-        suite, exec_errors = process_outputs(datasources, settings)
-        suite.set_options(settings)
-        RobotTestOutput.__init__(self, suite, exec_errors, settings)
-        self._namegen = utils.FileNameGenerator(settings['Log'])
-
-    def _create_split_sub_logs(self, suite, split_level, suite_level=0):
-        if suite_level < split_level:
-            for sub in suite.suites:
- self._create_split_sub_logs(sub, split_level, suite_level+1)
-        elif suite_level == split_level:
-            self._create_split_sub_log(suite, split_level)
-
-    def _create_split_sub_log(self, suite, split_level):
-        outfile = self._get_outfile(self._namegen.get_name(), 'log')
-        if not outfile:
-            return
- self._use_template(outfile, templates.LOG, '%s Test Log' % suite.name) - Statistics(suite).serialize(LogStatSerializer(outfile, split_level))
-        suite.serialize(LogSerializer(outfile, split_level))
-        outfile.write('</body>\n</html>\n')
-        outfile.close()
-
-
-class SplitSubTestOutput(RobotTestOutput):
-
-    def __init__(self, path, settings):
-        suite, exec_errors = process_output(path)
- suite.set_critical_tags(settings['Critical'], settings['NonCritical'])
-        RobotTestOutput.__init__(self, suite, exec_errors)
-
-
-class SplitIndexTestOutput(RobotTestOutput):
-
-    def __init__(self, runsuite, path, settings):
- # 'runsuite' is the one got when running tests and 'outsuite' is read
-        # from xml. The former contains information (incl. stats) about all
-        # tests but no messages. The latter contains messages but no info
-        # about tests in splitted outputs.
- outsuite, exec_errors = process_output(path, settings['SplitOutputs'])
-        self._update_stats(outsuite, runsuite)
-        RobotTestOutput.__init__(self, runsuite, exec_errors, settings)
-        self._outsuite = outsuite
-
-    def _update_stats(self, outsuite, runsuite):
-        outsuite.critical_stats = runsuite.critical_stats
-        outsuite.all_stats = runsuite.all_stats
-        outsuite.status = runsuite.status
-        for outsub, runsub in zip(outsuite.suites, runsuite.suites):
-            self._update_stats(outsub, runsub)
-
-    def _serialize_split_log(self, outfile, level):
-        self.statistics.serialize(SplitLogStatSerializer(outfile, level))
-        self.exec_errors.serialize(ErrorSerializer(outfile))
-        self._outsuite.serialize(SplitLogSerializer(outfile, level))

==============================================================================
Revision: 9d88d2b323e4
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 05:36:38 2011
Log:      testoutput: extracted classes for log and report building
http://code.google.com/p/robotframework/source/detail?r=9d88d2b323e4

Modified:
 /src/robot/serializing/testoutput.py

=======================================
--- /src/robot/serializing/testoutput.py        Wed Jun 15 04:56:54 2011
+++ /src/robot/serializing/testoutput.py        Wed Jun 15 05:36:38 2011
@@ -36,52 +36,17 @@
         self._suite = None
         self._settings = settings

-    def _make_report(self, report_path, data_model):
-        if report_path:
-            data_model.set_settings(self._get_report_settings())
-            serialize_report(data_model, report_path)
-            LOGGER.output_file('Report', report_path)
-
-    def _get_report_settings(self):
-        return {
-            'title': self._settings['ReportTitle'],
-            'background' : self._resolve_background_colors(),
-            'logURL': self._url_from_path(self._parse_file('Report'),
-                                          self._parse_file('Log'))
-        }
-
-    def _url_from_path(self, source, dest):
-        if not dest:
-            return None
-        return utils.get_link_path(dest, os.path.dirname(source))
-
-    def _resolve_background_colors(self):
-        color_str = self._settings['ReportBackground']
-        if color_str and color_str.count(':') not in [1, 2]:
-            LOGGER.error("Invalid background color '%s'." % color_str)
-            color_str = None
-        if not color_str:
-            color_str = '#99FF66:#FF3333'
-        colors = color_str.split(':', 2)
-        if len(colors) == 2:
-            colors.insert(1, colors[0])
- return {'pass': colors[0], 'nonCriticalFail': colors[1], 'fail': colors[2]}
-
-    def _make_log(self, log_path, data_model):
-        if log_path:
-            data_model.set_settings(self._get_log_settings())
-            serialize_log(data_model, log_path)
-            LOGGER.output_file('Log', log_path)
-
-    def _get_log_settings(self):
-        return {
-            'title': self._settings['ReportTitle'],
-            'reportURL': self._url_from_path(self._parse_file('Log'),
-                                             self._parse_file('Report'))
-        }
-
-    def _make_xunit(self, xunit_path, data_source):
-        if xunit_path:
+    def execute(self, data_source):
+        data_model = jsparser.create_datamodel_from(data_source)
+        data_model.set_generated(time.localtime())
+        LogBuilder(data_model, self._settings).create()
+        data_model.remove_keywords()
+        ReportBuilder(data_model, self._settings).create()
+        self._make_xunit(data_source)
+
+    def _make_xunit(self, data_source):
+        xunit_path = self._settings['XUnitFile']
+        if xunit_path != 'NONE':
self._robot_test_output([data_source]).serialize_xunit(xunit_path)

     def _robot_test_output(self, data_sources):
@@ -91,36 +56,78 @@
self._robot_test_output_cached = RobotTestOutput(self._suite, exec_errors, self._settings)
         return self._robot_test_output_cached

+    def execute_rebot(self, *data_sources):
+        combined = self._combine_outputs(data_sources)
+        self.execute(combined)
+        if self._temp_file:
+            os.remove(self._temp_file)
+        return self._suite
+
     def _combine_outputs(self, data_sources):
-        output_file = self._parse_file('Output')
-        if output_file is None:
+        output_file = self._settings['Output']
+        if output_file == 'NONE':
handle, output_file = tempfile.mkstemp(suffix='.xml', prefix='rebot-')
             os.close(handle)
             self._temp_file = output_file
self._robot_test_output(data_sources).serialize_output(output_file, log=not self._temp_file)
         return output_file

-    def execute_rebot(self, *data_sources):
-        combined = self._combine_outputs(data_sources)
-        self.execute(combined)
-        if self._temp_file:
-            os.remove(self._temp_file)
-        return self._suite
-
-    def execute(self, data_source):
-        data_model = jsparser.create_datamodel_from(data_source)
-        data_model.set_generated(time.localtime())
-        log_path = self._parse_file('Log')
-        report_path = self._parse_file('Report')
-        self._make_log(log_path, data_model)
-        data_model.remove_keywords()
-        self._make_report(report_path, data_model)
-        xunit_path = self._parse_file('XUnitFile')
-        self._make_xunit(xunit_path, data_source)
+
+class _Builder(object):
+
+    def __init__(self, data_model, settings):
+        self._settings = settings
+        self._path = self._parse_file(self._type)
+        self._data_model = data_model
+
+    def create(self):
+        if self._path:
+            self._data_model.set_settings(self._get_settings())
+            serialize_report(self._data_model, self._path)
+            LOGGER.output_file(self._type, self._path)

     def _parse_file(self, name):
         value = self._settings[name]
         return value if value != 'NONE' else None
+
+    def _url_from_path(self, source, dest):
+        if not dest:
+            return None
+        return utils.get_link_path(dest, os.path.dirname(source))
+
+
+class LogBuilder(_Builder):
+    _type = 'Log'
+
+    def _get_settings(self):
+        return {
+            'title': self._settings['LogTitle'],
+            'reportURL': self._url_from_path(self._path,
+                                             self._parse_file('Report'))
+        }
+
+class ReportBuilder(_Builder):
+    _type = 'Report'
+
+    def _get_settings(self):
+        return {
+            'title': self._settings['ReportTitle'],
+            'background' : self._resolve_background_colors(),
+            'logURL': self._url_from_path(self._path,
+                                          self._parse_file('Log'))
+        }
+
+    def _resolve_background_colors(self):
+        color_str = self._settings['ReportBackground']
+        if color_str and color_str.count(':') not in [1, 2]:
+            LOGGER.error("Invalid background color '%s'." % color_str)
+            color_str = None
+        if not color_str:
+            color_str = '#99FF66:#FF3333'
+        colors = color_str.split(':', 2)
+        if len(colors) == 2:
+            colors.insert(1, colors[0])
+ return {'pass': colors[0], 'nonCriticalFail': colors[1], 'fail': colors[2]}


 class RobotTestOutput:

==============================================================================
Revision: 01a83e97403b
Author:   Janne Härkönen <[email protected]>
Date:     Wed Jun 15 06:41:36 2011
Log:      Automated merge with https://robotframework.googlecode.com/hg/
http://code.google.com/p/robotframework/source/detail?r=01a83e97403b


Reply via email to