Bug 1125098 - Remove XML report functionality from Marionette test runner; r=maja_zf
authorShruti Jasoria <shrutijasoria1996@gmail.com>
Tue, 02 Feb 2016 19:24:51 +0530
changeset 329851 28adba6d7e46f1547ea885be2d016ae205dd8d2f
parent 329850 96958447062399b95f5fe6f665d0e554208bfee4
child 329852 62437a8123876ca69e54c68a40659704139ce2d5
push id10617
push userdtownsend@mozilla.com
push dateTue, 09 Feb 2016 16:30:19 +0000
reviewersmaja_zf
bugs1125098
milestone47.0a1
Bug 1125098 - Remove XML report functionality from Marionette test runner; r=maja_zf
testing/marionette/client/marionette/runner/base.py
testing/mozharness/configs/marionette/automation_emulator_config.py
testing/mozharness/configs/marionette/gaia_ui_test_prod_config.py
testing/mozharness/configs/marionette/prod_config.py
testing/mozharness/configs/marionette/test_config.py
testing/mozharness/configs/marionette/windows_config.py
--- a/testing/marionette/client/marionette/runner/base.py
+++ b/testing/marionette/client/marionette/runner/base.py
@@ -11,17 +11,17 @@ import os
 import random
 import socket
 import sys
 import time
 import traceback
 import unittest
 import warnings
 import mozprofile
-import xml.dom.minidom as dom
+
 
 from manifestparser import TestManifest
 from manifestparser.filters import tags
 from marionette_driver.marionette import Marionette
 from mixins.b2g import B2GTestResultMixin, get_b2g_pid, get_dm
 from mozlog import get_default_logger
 from moztest.adapters.unit import StructuredTestRunner, StructuredTestResult
 from moztest.results import TestResultCollection, TestResult, relevant_line
@@ -336,18 +336,16 @@ class BaseMarionetteArguments(ArgumentPa
                               " particular section."))
         self.add_argument('--addon',
                         action='append',
                         help="addon to install; repeat for multiple addons.")
         self.add_argument('--repeat',
                         type=int,
                         default=0,
                         help='number of times to repeat the test(s)')
-        self.add_argument('-x', '--xml-output',
-                        help='xml output')
         self.add_argument('--testvars',
                         action='append',
                         help='path to a json file with any test data required')
         self.add_argument('--tree',
                         default='b2g',
                         help='the tree that the revision parameter refers to')
         self.add_argument('--symbols-path',
                         help='absolute path to directory containing breakpad symbols, or the url of a zip file containing symbols')
@@ -513,17 +511,17 @@ class BaseMarionetteTestRunner(object):
 
     textrunnerclass = MarionetteTextTestRunner
     driverclass = Marionette
 
     def __init__(self, address=None, emulator=None, emulator_binary=None,
                  emulator_img=None, emulator_res='480x800', homedir=None,
                  app=None, app_args=None, binary=None, profile=None,
                  logger=None, no_window=False, logdir=None, logcat_stdout=False,
-                 xml_output=None, repeat=0, testvars=None, tree=None, type=None,
+                 repeat=0, testvars=None, tree=None, type=None,
                  device_serial=None, symbols_path=None, timeout=None,
                  shuffle=False, shuffle_seed=random.randint(0, sys.maxint),
                  sdcard=None, this_chunk=1, total_chunks=1, sources=None,
                  server_root=None, gecko_log=None, result_callbacks=None,
                  adb_host=None, adb_port=None, prefs=None, test_tags=None,
                  socket_timeout=BaseMarionetteArguments.socket_timeout_default,
                  startup_timeout=None, addons=None, workspace=None,
                  verbose=0, **kwargs):
@@ -539,17 +537,16 @@ class BaseMarionetteTestRunner(object):
         self.profile = profile
         self.addons = addons
         self.logger = logger
         self.no_window = no_window
         self.httpd = None
         self.marionette = None
         self.logdir = logdir
         self.logcat_stdout = logcat_stdout
-        self.xml_output = xml_output
         self.repeat = repeat
         self.test_kwargs = kwargs
         self.tree = tree
         self.type = type
         self.device_serial = device_serial
         self.symbols_path = symbols_path
         self.timeout = timeout
         self.socket_timeout = socket_timeout
@@ -635,18 +632,16 @@ class BaseMarionetteTestRunner(object):
         if self.logdir and not os.access(self.logdir, os.F_OK):
                 os.mkdir(self.logdir)
 
         if not gecko_log:
             self.gecko_log = os.path.join(self.workspace_path or '', 'gecko.log')
         else:
             self.gecko_log = gecko_log
 
-        # for XML output
-        self.testvars['xml_output'] = self.xml_output
         self.results = []
 
     @property
     def capabilities(self):
         if self._capabilities:
             return self._capabilities
 
         self.marionette.start_session()
@@ -920,23 +915,16 @@ setReq.onerror = function() {
         try:
             self.marionette.check_for_crash()
         except:
             traceback.print_exc()
 
         self.end_time = time.time()
         self.elapsedtime = self.end_time - self.start_time
 
-        if self.xml_output:
-            xml_dir = os.path.dirname(os.path.abspath(self.xml_output))
-            if not os.path.exists(xml_dir):
-                os.makedirs(xml_dir)
-            with open(self.xml_output, 'w') as f:
-                f.write(self.generate_xml(self.results))
-
         if self.marionette.instance:
             self.marionette.instance.close()
             self.marionette.instance = None
 
         self.marionette.cleanup()
 
         for run_tests in self.mixin_run_tests:
             run_tests(tests)
@@ -1115,98 +1103,9 @@ setReq.onerror = function() {
 
     def cleanup(self):
         if self.httpd:
             self.httpd.stop()
 
         if self.marionette:
             self.marionette.cleanup()
 
-    __del__ = cleanup
-
-    def generate_xml(self, results_list):
-
-        def _extract_xml_from_result(test_result, result='passed'):
-            _extract_xml(
-                test_name=unicode(test_result.name).split()[0],
-                test_class=test_result.test_class,
-                duration=test_result.duration,
-                result=result,
-                output='\n'.join(test_result.output))
-
-        def _extract_xml_from_skipped_manifest_test(test):
-            _extract_xml(
-                test_name=test['name'],
-                result='skipped',
-                output=test['disabled'])
-
-        def _extract_xml(test_name, test_class='', duration=0,
-                         result='passed', output=''):
-            testcase = doc.createElement('testcase')
-            testcase.setAttribute('classname', test_class)
-            testcase.setAttribute('name', test_name)
-            testcase.setAttribute('time', str(duration))
-            testsuite.appendChild(testcase)
-
-            if result in ['failure', 'error', 'skipped']:
-                f = doc.createElement(result)
-                f.setAttribute('message', 'test %s' % result)
-                f.appendChild(doc.createTextNode(output))
-                testcase.appendChild(f)
-
-        doc = dom.Document()
-
-        testsuite = doc.createElement('testsuite')
-        testsuite.setAttribute('name', 'Marionette')
-        testsuite.setAttribute('time', str(self.elapsedtime))
-        testsuite.setAttribute('tests', str(sum([results.testsRun for
-                                                 results in results_list])))
-
-        def failed_count(results):
-            count = len(results.failures)
-            if hasattr(results, 'unexpectedSuccesses'):
-                count += len(results.unexpectedSuccesses)
-            return count
-
-        testsuite.setAttribute('failures', str(sum([failed_count(results)
-                                               for results in results_list])))
-        testsuite.setAttribute('errors', str(sum([len(results.errors)
-                                             for results in results_list])))
-        testsuite.setAttribute(
-            'skips', str(sum([len(results.skipped) +
-                         len(results.expectedFailures)
-                         for results in results_list]) +
-                         len(self.manifest_skipped_tests)))
-
-        for results in results_list:
-
-            for result in results.errors:
-                _extract_xml_from_result(result, result='error')
-
-            for result in results.failures:
-                _extract_xml_from_result(result, result='failure')
-
-            if hasattr(results, 'unexpectedSuccesses'):
-                for test in results.unexpectedSuccesses:
-                    # unexpectedSuccesses is a list of Testcases only, no tuples
-                    _extract_xml_from_result(test, result='failure')
-
-            if hasattr(results, 'skipped'):
-                for result in results.skipped:
-                    _extract_xml_from_result(result, result='skipped')
-
-            if hasattr(results, 'expectedFailures'):
-                for result in results.expectedFailures:
-                    _extract_xml_from_result(result, result='skipped')
-
-            for result in results.tests_passed:
-                _extract_xml_from_result(result)
-
-        for test in self.manifest_skipped_tests:
-            _extract_xml_from_skipped_manifest_test(test)
-
-        doc.appendChild(testsuite)
-
-        # change default encoding to avoid encoding problem for page source
-        reload(sys)
-        sys.setdefaultencoding('utf-8')
-
-        return doc.toprettyxml(encoding='utf-8')
+    __del__ = cleanup
\ No newline at end of file
--- a/testing/mozharness/configs/marionette/automation_emulator_config.py
+++ b/testing/mozharness/configs/marionette/automation_emulator_config.py
@@ -47,17 +47,17 @@ config = {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
                 "--gecko-log=%(gecko_log)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--binary=%(binary)s",
                 "--address=%(address)s",
                 "--total-chunks=%(total_chunks)s",
                 "--this-chunk=%(this_chunk)s"
             ],
@@ -67,17 +67,17 @@ config = {
         "gaiatest_emulator": {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--logcat-dir=%(logcat_dir)s",
                 "--emulator=%(emulator)s",
                 "--homedir=%(homedir)s"
             ],
             "run_filename": "",
--- a/testing/mozharness/configs/marionette/gaia_ui_test_prod_config.py
+++ b/testing/mozharness/configs/marionette/gaia_ui_test_prod_config.py
@@ -55,17 +55,17 @@ config = {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
                 "--gecko-log=%(gecko_log)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--binary=%(binary)s",
                 "--address=%(address)s",
                 "--total-chunks=%(total_chunks)s",
                 "--this-chunk=%(this_chunk)s"
             ],
@@ -75,17 +75,17 @@ config = {
         "gaiatest_emulator": {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--logcat-dir=%(logcat_dir)s",
                 "--emulator=%(emulator)s",
                 "--homedir=%(homedir)s"
             ],
             "run_filename": "",
--- a/testing/mozharness/configs/marionette/prod_config.py
+++ b/testing/mozharness/configs/marionette/prod_config.py
@@ -44,17 +44,17 @@ config = {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
                 "--gecko-log=%(gecko_log)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--binary=%(binary)s",
                 "--address=%(address)s",
                 "--total-chunks=%(total_chunks)s",
                 "--this-chunk=%(this_chunk)s"
             ],
@@ -64,17 +64,17 @@ config = {
         "gaiatest_emulator": {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--logcat-dir=%(logcat_dir)s",
                 "--emulator=%(emulator)s",
                 "--homedir=%(homedir)s"
             ],
             "run_filename": "",
--- a/testing/mozharness/configs/marionette/test_config.py
+++ b/testing/mozharness/configs/marionette/test_config.py
@@ -18,17 +18,17 @@ config = {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
                 "--gecko-log=%(gecko_log)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--binary=%(binary)s",
                 "--address=%(address)s",
                 "--total-chunks=%(total_chunks)s",
                 "--this-chunk=%(this_chunk)s"
             ],
@@ -38,17 +38,17 @@ config = {
         "gaiatest_emulator": {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--logcat-dir=%(logcat_dir)s",
                 "--emulator=%(emulator)s",
                 "--homedir=%(homedir)s"
             ],
             "run_filename": "",
--- a/testing/mozharness/configs/marionette/windows_config.py
+++ b/testing/mozharness/configs/marionette/windows_config.py
@@ -46,17 +46,17 @@ config = {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
                 "--gecko-log=%(gecko_log)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--binary=%(binary)s",
                 "--address=%(address)s",
                 "--total-chunks=%(total_chunks)s",
                 "--this-chunk=%(this_chunk)s"
             ],
@@ -66,17 +66,17 @@ config = {
         "gaiatest_emulator": {
             "options": [
                 "--restart",
                 "--timeout=%(timeout)s",
                 "--type=%(type)s",
                 "--testvars=%(testvars)s",
                 "--profile=%(profile)s",
                 "--symbols-path=%(symbols_path)s",
-                "--xml-output=%(xml_output)s",
+                "--log-xunit=%(xml_output)s",
                 "--html-output=%(html_output)s",
                 "--log-raw=%(raw_log_file)s",
                 "--log-errorsummary=%(error_summary_file)s",
                 "--logcat-dir=%(logcat_dir)s",
                 "--emulator=%(emulator)s",
                 "--homedir=%(homedir)s"
             ],
             "run_filename": "",