Bug 1298771 - Attach last-update.log to update results for Firefox UI update tests
MozReview-Commit-ID: DtNwBbPuHPy
--- a/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
+++ b/testing/firefox-ui/harness/firefox_ui_harness/testcases.py
@@ -1,12 +1,13 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import os
import pprint
from datetime import datetime
import mozfile
from marionette import MarionetteTestCase
from marionette_driver import Wait
@@ -109,20 +110,22 @@ class UpdateTestCase(FirefoxTestCase):
# Check if the user has permissions to run the update
self.assertTrue(self.software_update.allowed,
'Current user has permissions to update the application.')
def tearDown(self):
try:
self.browser.tabbar.close_all_tabs([self.browser.tabbar.selected_tab])
+ # Add content of the update log file for detailed failures when applying an update
+ self.updates[self.current_update_index]['update_log'] = self.read_update_log()
+
# Print results for now until we have treeherder integration
output = pprint.pformat(self.updates)
self.logger.info('Update test results: \n{}'.format(output))
-
finally:
super(UpdateTestCase, self).tearDown()
# Ensure that no trace of an partially downloaded update remain
self.remove_downloaded_update()
self.restore_config_files()
@@ -350,21 +353,35 @@ class UpdateTestCase(FirefoxTestCase):
dialog.close()
finally:
self.updates[self.current_update_index]['patch'] = self.patch_info
# Restart Firefox to apply the update
self.restart()
+ def read_update_log(self):
+ """Read the content of the update log file for the last update attempt."""
+ path = os.path.join(os.path.dirname(self.software_update.staging_directory),
+ 'last-update.log')
+ try:
+ with open(path, 'rb') as f:
+ return f.read().splitlines()
+ except IOError as exc:
+ self.logger.warning(str(exc))
+ return None
+
def remove_downloaded_update(self):
- """Remove an already downloaded update from the update staging directory."""
- self.logger.info('Clean-up update staging directory: {}'.format(
- self.software_update.staging_directory))
- mozfile.remove(self.software_update.staging_directory)
+ """Remove an already downloaded update from the update staging directory.
+
+ Hereby not only remove the update subdir but everything below 'updates'.
+ """
+ path = os.path.dirname(self.software_update.staging_directory)
+ self.logger.info('Clean-up update staging directory: {}'.format(path))
+ mozfile.remove(path)
def restore_config_files(self):
# Reset channel-prefs.js file if modified
try:
if self.default_update_channel:
path = self.default_update_channel['path']
self.logger.info('Restoring channel defaults for: {}'.format(path))
with open(path, 'w') as f: