[GRASS-SVN] r61494 - grass/trunk/lib/python/gunittest

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 31 21:08:21 PDT 2014


Author: wenzeslaus
Date: 2014-07-31 21:08:21 -0700 (Thu, 31 Jul 2014)
New Revision: 61494

Modified:
   grass/trunk/lib/python/gunittest/invoker.py
   grass/trunk/lib/python/gunittest/multireport.py
   grass/trunk/lib/python/gunittest/reporters.py
Log:
gunittest: index page for report with two links (to testsuites and to test files), proper HTML header for file with Unicode character (atempt to fix it in Chrome)

Modified: grass/trunk/lib/python/gunittest/invoker.py
===================================================================
--- grass/trunk/lib/python/gunittest/invoker.py	2014-08-01 00:52:44 UTC (rev 61493)
+++ grass/trunk/lib/python/gunittest/invoker.py	2014-08-01 04:08:21 UTC (rev 61494)
@@ -183,7 +183,8 @@
             reporters=[
                 GrassTestFilesTextReporter(stream=sys.stderr),
                 GrassTestFilesHtmlReporter(
-                    file_anonymizer=self._file_anonymizer),
+                    file_anonymizer=self._file_anonymizer,
+                    main_page_name='testfiles.html'),
                 GrassTestFilesKeyValueReporter(
                     info=dict(location=location, location_type=location_type))
             ])
@@ -204,6 +205,21 @@
                                   gisdbase=gisdbase, location=location)
         self.reporter.finish()
 
+        # TODO: move this to some (new?) reporter
+        # TODO: add basic summary of linked files so that the page is not empty
+        with open(os.path.join(results_dir, 'index.html'), 'w') as main_index:
+            main_index.write(
+                '<html><body>'
+                '<h1>Tests for <{location}>'
+                ' using <{type}> type tests</h1>'
+                '<ul>'
+                '<li><a href="testsuites.html">Results by testsuites</a>'
+                ' (testsuite directories)</li>'
+                '<li><a href="testfiles.html">Results by test files</a></li>'
+                '<ul>'
+                '</body></html>'
+                .format(location=location, type=location_type))
+
         testsuite_dir_reporter = TestsuiteDirReporter(
             main_page_name='testsuites.html', testsuite_page_name='index.html',
             top_level_testsuite_page_name='testsuite_index.html')

Modified: grass/trunk/lib/python/gunittest/multireport.py
===================================================================
--- grass/trunk/lib/python/gunittest/multireport.py	2014-08-01 00:52:44 UTC (rev 61493)
+++ grass/trunk/lib/python/gunittest/multireport.py	2014-08-01 04:08:21 UTC (rev 61494)
@@ -238,7 +238,7 @@
             # let's consider no location as valid state and use 'unknown'
             result.location = summary.get('location', 'unknown')
             result.location_type = summary.get('location_type', 'unknown')
-            # grouping accoring to location types
+            # grouping according to location types
             # this can cause that two actual locations tested at the same time
             # will end up together, this is not ideal but testing with
             # one location type and different actual locations is not standard
@@ -254,7 +254,7 @@
     locations_main_page = open(os.path.join(output, 'index.html'), 'w')
     locations_main_page.write(
         '<html><body>'
-        '<h1>Test reports accoring to locations</h1>'
+        '<h1>Test reports grouped by location type</h1>'
         '<table>'
         '<thead><tr>'
         '<th>Location</th>'
@@ -272,7 +272,8 @@
         if location_type == 'unknown':
             title = 'Test reports'
         else:
-            title = 'Test reports for ' + location_type + ' location'
+            title = ('Test reports for <{type}> location type'
+                     .format(type=location_type))
 
         x = [date2num(result.timestamp) for result in results]
         xlabels = [result.timestamp.strftime("%Y-%m-%d") + ' (r' + result.svn_revision + ')' for result in results]

Modified: grass/trunk/lib/python/gunittest/reporters.py
===================================================================
--- grass/trunk/lib/python/gunittest/reporters.py	2014-08-01 00:52:44 UTC (rev 61493)
+++ grass/trunk/lib/python/gunittest/reporters.py	2014-08-01 04:08:21 UTC (rev 61494)
@@ -498,15 +498,17 @@
 
     unknown_number = UNKNOWN_NUMBER_HTML
 
-    def __init__(self, file_anonymizer):
+    def __init__(self, file_anonymizer, main_page_name='index.html'):
         super(GrassTestFilesHtmlReporter, self).__init__()
         self.main_index = None
         self._file_anonymizer = file_anonymizer
+        self._main_page_name = main_page_name
 
     def start(self, results_dir):
         super(GrassTestFilesHtmlReporter, self).start(results_dir)
         # having all variables public although not really part of API
-        self.main_index = open(os.path.join(results_dir, 'index.html'), 'w')
+        main_page_name = os.path.join(results_dir, self._main_page_name)
+        self.main_index = open(main_page_name, 'w')
 
         # TODO: this can be moved to the counter class
         self.failures = 0
@@ -649,7 +651,7 @@
         file_index_path = os.path.join(cwd, 'index.html')
         file_index = open(file_index_path, 'w')
         file_index.write(
-            '<html><body>'
+            '<!DOCTYPE html><html><head><meta charset="utf-8"></head><body>'
             '<h1>{m.name}</h1>'
             '<h2>{m.tested_dir} – {m.name}</h2>'
             '{status}'



More information about the grass-commit mailing list