4 new revisions:

Revision: e25ff8672314
Author:   Pekka Klärck
Date:     Thu Jan  5 03:28:11 2012
Log:      easier configuration of JsResultWriter
http://code.google.com/p/robotframework/source/detail?r=e25ff8672314

Revision: 8f83fc532e2b
Author:   Pekka Klärck
Date:     Thu Jan  5 03:50:37 2012
Log:      cleanup
http://code.google.com/p/robotframework/source/detail?r=8f83fc532e2b

Revision: cd7d775d11c8
Author:   Pekka Klärck
Date:     Thu Jan  5 03:57:27 2012
Log:      resultwriter.Result: accept also single data source
http://code.google.com/p/robotframework/source/detail?r=cd7d775d11c8

Revision: b9727b6f7fa4
Author:   Pekka Klärck
Date:     Thu Jan  5 04:01:34 2012
Log:      cleanup
http://code.google.com/p/robotframework/source/detail?r=b9727b6f7fa4

==============================================================================
Revision: e25ff8672314
Author:   Pekka Klärck
Date:     Thu Jan  5 03:28:11 2012
Log:      easier configuration of JsResultWriter
http://code.google.com/p/robotframework/source/detail?r=e25ff8672314

Modified:
 /src/robot/reporting/jswriter.py
 /src/robot/webcontent/testdata/create_jsdata.py
 /utest/reporting/test_jswriter.py
 /utest/webcontent/spec/data/create_jsdata_for_specs.py

=======================================
--- /src/robot/reporting/jswriter.py    Wed Dec 14 13:19:53 2011
+++ /src/robot/reporting/jswriter.py    Thu Jan  5 03:28:11 2012
@@ -18,19 +18,21 @@


 class JsResultWriter(object):
-    start_block = '<script type="text/javascript">' + os.linesep
-    end_block = '</script>' + os.linesep
-    split_threshold = 9500
     _output_attr = 'window.output'
     _settings_attr = 'window.settings'
     _suite_key = 'suite'
     _strings_key = 'strings'

-    def __init__(self, output):
-        block_separator = self.end_block + self.start_block
-        writer = JsonWriter(output, separator=block_separator)
+    def __init__(self, output,
+ start_block='<script type="text/javascript">' + os.linesep,
+                 end_block='</script>' + os.linesep,
+                 split_threshold=9500):
+        writer = JsonWriter(output, separator=end_block+start_block)
         self._write = writer.write
         self._write_json = writer.write_json
+        self._start_block = start_block
+        self._end_block = end_block
+        self._split_threshold = split_threshold

     def write(self, result, settings):
         self._start_output_block()
@@ -40,11 +42,11 @@
         self._write_settings_and_end_output_block(settings)

     def _start_output_block(self):
-        self._write(self.start_block, postfix='', separator=False)
+        self._write(self._start_block, postfix='', separator=False)
         self._write('%s = {}' % self._output_attr)

     def _write_suite(self, suite):
-        writer = SuiteWriter(self._write_json, self.split_threshold)
+        writer = SuiteWriter(self._write_json, self._split_threshold)
         writer.write(suite, self._output_var(self._suite_key))

     def _write_strings(self, strings):
@@ -52,7 +54,7 @@
         self._write('%s = []' % variable)
         prefix = '%s = %s.concat(' % (variable, variable)
         postfix = ');' + os.linesep
-        threshold = self.split_threshold
+        threshold = self._split_threshold
         for index in xrange(0, len(strings), threshold):
self._write_json(prefix, strings[index:index+threshold], postfix)

@@ -62,8 +64,8 @@

     def _write_settings_and_end_output_block(self, settings):
         self._write_json('%s = ' % self._settings_attr, settings,
-                                separator=False)
-        self._write(self.end_block, postfix='', separator=False)
+                         separator=False)
+        self._write(self._end_block, postfix='', separator=False)

     def _output_var(self, key):
         return '%s["%s"]' % (self._output_attr, key)
=======================================
--- /src/robot/webcontent/testdata/create_jsdata.py     Wed Jan  4 15:44:02 2012
+++ /src/robot/webcontent/testdata/create_jsdata.py     Thu Jan  5 03:28:11 2012
@@ -20,11 +20,6 @@
 from robot.reporting.jswriter import JsResultWriter


-class ResultWriter(JsResultWriter):
-    start_block = ''
-    end_block = ''
-
-
 def run_robot(testdata, outxml):
     robot.run(testdata, log='NONE', report='NONE', output=outxml)

@@ -39,11 +34,12 @@
              tagstatcombine=['fooANDi*:No Match', 'i?:IX'],
              critical=['i?'], noncritical=['*kek*kone*']))
     result = Results([outxml], settings).js_result
-    config = dict(logURL='log.html',
-                  reportURL='report.html',
-                  background={'fail': 'DeepPink'})
+    config = {'logURL': 'log.html',
+              'reportURL': 'report.html',
+              'background': {'fail': 'DeepPink'}}
     with codecs.open(target, 'w', 'UTF-8') as output:
-        ResultWriter(output).write(result, config)
+        writer = JsResultWriter(output, start_block='', end_block='')
+        writer.write(result, config)


 if __name__ == '__main__':
=======================================
--- /utest/reporting/test_jswriter.py   Mon Dec 12 13:19:20 2011
+++ /utest/reporting/test_jswriter.py   Thu Jan  5 03:28:11 2012
@@ -10,9 +10,7 @@
               end_block='', split_threshold=9999):
     output = StringIO()
     data = JsExecutionResult(suite, None, None, strings, basemillis)
-    attrs = {'start_block': start_block, 'end_block': end_block,
-             'split_threshold': split_threshold}
-    writer = type('CustomWriter', (JsResultWriter,), attrs)(output)
+ writer = JsResultWriter(output, start_block, end_block, split_threshold)
     writer.write(data, settings={})
     return output.getvalue().splitlines()

=======================================
--- /utest/webcontent/spec/data/create_jsdata_for_specs.py Fri Dec 9 04:37:25 2011 +++ /utest/webcontent/spec/data/create_jsdata_for_specs.py Thu Jan 5 03:28:11 2012
@@ -17,11 +17,6 @@
 from robot.reporting.jswriter import JsResultWriter, JsonWriter


-class NonBlockingJsResultWriter(JsResultWriter):
-    start_block = ''
-    end_block = '\n'
-
-
 def run_robot(testdata, loglevel='INFO'):
     robot.run(testdata, log='NONE', report='NONE',
               tagstatlink=['force:http://google.com:<kuukkeli&gt;',
@@ -38,7 +33,7 @@
               'reportURL': 'report.html',
               'background': {'fail': 'DeepPink'}}
     with open(target, 'w') as output:
-        NonBlockingJsResultWriter(output).write(model, config)
+ JsResultWriter(output, start_block='', end_block='\n').write(model, config)
         writer = JsonWriter(output)
         for index, (keywords, strings) in enumerate(model.split_results):
writer.write_json('window.outputKeywords%d = ' % index, keywords)

==============================================================================
Revision: 8f83fc532e2b
Author:   Pekka Klärck
Date:     Thu Jan  5 03:50:37 2012
Log:      cleanup
http://code.google.com/p/robotframework/source/detail?r=8f83fc532e2b

Modified:
 /utest/webcontent/spec/data/create_jsdata_for_specs.py

=======================================
--- /utest/webcontent/spec/data/create_jsdata_for_specs.py Thu Jan 5 03:28:11 2012 +++ /utest/webcontent/spec/data/create_jsdata_for_specs.py Thu Jan 5 03:50:37 2012
@@ -5,62 +5,53 @@
 import sys
 import os

-
 BASEDIR = dirname(abspath(__file__))
 OUTPUT = join(BASEDIR, 'output.xml')

 sys.path.insert(0, join(BASEDIR, '..', '..', '..', '..', 'src'))

 import robot
-from robot.result.executionresult import ResultFromXml
-from robot.reporting.jsmodelbuilders import JsModelBuilder
+from robot.conf.settings import RebotSettings
+from robot.reporting.resultwriter import Results
 from robot.reporting.jswriter import JsResultWriter, JsonWriter


-def run_robot(testdata, loglevel='INFO'):
-    robot.run(testdata, log='NONE', report='NONE',
-              tagstatlink=['force:http://google.com:<kuukkeli&gt;',
-                           'i*:http://%1/:Title of i%1'],
-              tagdoc=['test:this_is_*my_bold*_test',
-                      'IX:*Combined* & escaped <&lt; tag doc'],
-              tagstatcombine=['fooANDi*:zap', 'i?:IX'],
- critical=[], noncritical=[], outputdir=BASEDIR, loglevel=loglevel)
+def create(testdata, target, split_log=False):
+    testdata = join(BASEDIR, testdata)
+    output_name = target[0].lower() + target[1:-3] + 'Output'
+    target = join(BASEDIR, target)
+    run_robot(testdata)
+    create_jsdata(target, split_log)
+    inplace_replace_all(target, 'window.output', 'window.' + output_name)


-def create_jsdata(outxml, target, split_log):
- model = JsModelBuilder(split_log=split_log).build_from(ResultFromXml(outxml))
-    config = {'logURL': 'log.html',
-              'reportURL': 'report.html',
-              'background': {'fail': 'DeepPink'}}
+def run_robot(testdata, output=OUTPUT):
+    robot.run(testdata, log='NONE', report='NONE', output=output)
+
+
+def create_jsdata(target, split_log, outxml=OUTPUT):
+ result = Results(outxml, RebotSettings({'splitlog': split_log})).js_result + config = {'logURL': 'log.html', 'reportURL': 'report.html', 'background': {'fail': 'DeepPink'}}
     with open(target, 'w') as output:
- JsResultWriter(output, start_block='', end_block='\n').write(model, config) + JsResultWriter(output, start_block='', end_block='\n').write(result, config)
         writer = JsonWriter(output)
-        for index, (keywords, strings) in enumerate(model.split_results):
+        for index, (keywords, strings) in enumerate(result.split_results):
writer.write_json('window.outputKeywords%d = ' % index, keywords)
             writer.write_json('window.outputStrings%d = ' % index, strings)

-def replace_all(file,searchExp,replaceExp):
+
+def inplace_replace_all(file, search, replace):
     for line in fileinput.input(file, inplace=1):
-        if searchExp in line:
-            line = line.replace(searchExp,replaceExp)
-        sys.stdout.write(line)
-
-
-def create(input, target, targetName, loglevel='INFO', split_log=False):
-    input = join(BASEDIR, input)
-    target = join(BASEDIR, target)
-    run_robot(input, loglevel)
-    create_jsdata(OUTPUT, target, split_log)
-    replace_all(target, 'window.output', 'window.' + targetName)
+        sys.stdout.write(line.replace(search, replace))


 if __name__ == '__main__':
-    create('Suite.txt', 'Suite.js', 'suiteOutput')
- create('SetupsAndTeardowns.txt', 'SetupsAndTeardowns.js', 'setupsAndTeardownsOutput')
-    create('Messages.txt', 'Messages.js', 'messagesOutput')
- create('teardownFailure', 'TeardownFailure.js', 'teardownFailureOutput') - create(join('teardownFailure', 'PassingFailing.txt'), 'PassingFailing.js', 'passingFailingOutput') - create('TestsAndKeywords.txt', 'TestsAndKeywords.js', 'testsAndKeywordsOutput')
-    create('.', 'allData.js', 'allDataOutput')
-    create('.', 'splitting.js', 'splittingOutput', split_log=True)
+    create('Suite.txt', 'Suite.js')
+    create('SetupsAndTeardowns.txt', 'SetupsAndTeardowns.js')
+    create('Messages.txt', 'Messages.js')
+    create('teardownFailure', 'TeardownFailure.js')
+ create(join('teardownFailure', 'PassingFailing.txt'), 'PassingFailing.js')
+    create('TestsAndKeywords.txt', 'TestsAndKeywords.js')
+    create('.', 'allData.js')
+    create('.', 'splitting.js', split_log=True)
     os.remove(OUTPUT)

==============================================================================
Revision: cd7d775d11c8
Author:   Pekka Klärck
Date:     Thu Jan  5 03:57:27 2012
Log:      resultwriter.Result: accept also single data source
http://code.google.com/p/robotframework/source/detail?r=cd7d775d11c8

Modified:
 /src/robot/reporting/resultwriter.py

=======================================
--- /src/robot/reporting/resultwriter.py        Sun Dec 18 16:32:16 2011
+++ /src/robot/reporting/resultwriter.py        Thu Jan  5 03:57:27 2012
@@ -81,7 +81,8 @@
 class Results(object):

     def __init__(self, data_sources, settings):
-        self._data_sources = data_sources
+        self._data_sources = data_sources \
+            if not isinstance(data_sources, basestring) else [data_sources]
         self._settings = settings
         self._result = None
         self._js_result = None

==============================================================================
Revision: b9727b6f7fa4
Author:   Pekka Klärck
Date:     Thu Jan  5 04:01:34 2012
Log:      cleanup
http://code.google.com/p/robotframework/source/detail?r=b9727b6f7fa4

Modified:
 /src/robot/webcontent/testdata/create_jsdata.py

=======================================
--- /src/robot/webcontent/testdata/create_jsdata.py     Thu Jan  5 03:28:11 2012
+++ /src/robot/webcontent/testdata/create_jsdata.py     Thu Jan  5 04:01:34 2012
@@ -25,21 +25,24 @@


 def create_jsdata(outxml, target):
-    print outxml
-    settings = RebotSettings(
-        dict(tagstatlink=['force:http://google.com:<kuukkeli&gt;',
-                          'i*:http://%1/:Title of i%1'],
-             tagdoc=['test:this_is_*my_bold*_test',
-                     'IX:*Combined* & escaped <&lt; tag doc'],
-             tagstatcombine=['fooANDi*:No Match', 'i?:IX'],
-             critical=['i?'], noncritical=['*kek*kone*']))
-    result = Results([outxml], settings).js_result
+    settings = RebotSettings({
+        'critical': ['i?'],
+        'noncritical': ['*kek*kone*'],
+        'tagstatlink': ['force:http://google.com:<kuukkeli&gt;',
+                        'i*:http://%1/:Title of i%1'],
+        'tagdoc': ['test:this_is_*my_bold*_test',
+                   'IX:*Combined* & escaped <&lt; tag doc'],
+        'tagstatcombine': ['fooANDi*:No Match', 'i?:IX']
+    })
+    result = Results(outxml, settings).js_result
     config = {'logURL': 'log.html',
               'reportURL': 'report.html',
               'background': {'fail': 'DeepPink'}}
     with codecs.open(target, 'w', 'UTF-8') as output:
         writer = JsResultWriter(output, start_block='', end_block='')
         writer.write(result, config)
+    print 'Log:    ', normpath(join(BASEDIR, '..', 'log.html'))
+    print 'Report: ', normpath(join(BASEDIR, '..', 'report.html'))


 if __name__ == '__main__':

Reply via email to