소스 검색

gunittest: different name for toplevel testsuite index (because of conflict with main index), close file, and finish main test files index sooner

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61439 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 10 년 전
부모
커밋
7b6bd1785a
2개의 변경된 파일11개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 2
      lib/python/gunittest/invoker.py
  2. 8 1
      lib/python/gunittest/reporters.py

+ 3 - 2
lib/python/gunittest/invoker.py

@@ -196,9 +196,10 @@ class GrassTestFilesInvoker(object):
         for module in modules:
             self._run_test_module(module=module, results_dir=results_dir,
                                   gisdbase=gisdbase, location=location)
+        self.reporter.finish()
 
         testsuite_dir_reporter = TestsuiteDirReporter(
-            main_page_name='testsuites.html')
+            main_page_name='testsuites.html', testsuite_page_name='index.html',
+            top_level_testsuite_page_name='testsuite_index.html')
         testsuite_dir_reporter.report_for_dirs(root=results_dir,
                                                directories=self.testsuite_dirs)
-        self.reporter.finish()

+ 8 - 1
lib/python/gunittest/reporters.py

@@ -919,9 +919,11 @@ class GrassTestFilesTextReporter(GrassTestFilesCountingReporter):
 # TODO: add also keyvalue summary generation?
 # wouldn't this conflict with collecting data from report afterwards?
 class TestsuiteDirReporter(object):
-    def __init__(self, main_page_name, testsuite_page_name='index.html'):
+    def __init__(self, main_page_name, testsuite_page_name='index.html',
+                 top_level_testsuite_page_name=None):
         self.main_page_name = main_page_name
         self.testsuite_page_name = testsuite_page_name
+        self.top_level_testsuite_page_name = top_level_testsuite_page_name
 
         # TODO: this might be even a object which could add and validate
         self.failures = 0
@@ -954,6 +956,10 @@ class TestsuiteDirReporter(object):
         file_successes = 0
 
         page_name = os.path.join(root, directory, self.testsuite_page_name)
+        if (self.top_level_testsuite_page_name and
+                os.path.abspath(os.path.join(root, directory))
+                == os.path.abspath(root)):
+            page_name = os.path.join(root, self.top_level_testsuite_page_name)
         page = open(page_name, 'w')
         head = (
             '<html><body>'
@@ -1056,6 +1062,7 @@ class TestsuiteDirReporter(object):
             directory=directory, tests_authors=test_files_authors)
         page.write(test_authors)
         page.write('</body></html>')
+        page.close()
 
         status = success_to_html_text(total=file_total, successes=file_successes)
         row = (