author | Brian R. Bondy <netzen@gmail.com> |
Mon, 06 Apr 2015 12:03:18 -0400 (2015-04-06) | |
changeset 237696 | c3dc05ca2b4a1b1971e9c380151974d792b35148 |
parent 237695 | a0d5f4706bd24be060f97c3d88d72c7d842eb174 |
child 237697 | fc00de5d587f9007945ac896a99314919eb26955 |
push id | 28546 |
push user | netzen@gmail.com |
push date | Mon, 06 Apr 2015 16:08:39 +0000 (2015-04-06) |
treeherder | mozilla-central@883e17fc475f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | rstrong |
bugs | 973933 |
milestone | 40.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/toolkit/mozapps/update/tests/chrome/utils.js +++ b/toolkit/mozapps/update/tests/chrome/utils.js @@ -124,16 +124,17 @@ const { classes: Cc, interfaces: Ci, manager: Cm, results: Cr, utils: Cu } = Components; Cu.import("resource://gre/modules/AddonManager.jsm", this); Cu.import("resource://gre/modules/Services.jsm", this); const IS_MACOSX = ("nsILocalFileMac" in Ci); +const IS_WIN = ("@mozilla.org/windows-registry-key;1" in Cc); // The tests have to use the pageid instead of the pageIndex due to the // app update wizard's access method being random. const PAGEID_DUMMY = "dummy"; // Done const PAGEID_CHECKING = "checking"; // Done const PAGEID_PLUGIN_UPDATES = "pluginupdatesfound"; const PAGEID_NO_UPDATES_FOUND = "noupdatesfound"; // Done const PAGEID_MANUAL_UPDATE = "manualUpdate"; // Tested on license load failure @@ -178,16 +179,20 @@ const TEST_ADDONS = [ "appdisabled_1", " "compatible_1", "compatible_2", "noupdate_1", "noupdate_2", "updatecompatibility_1", "updatecompatibility_2", "updateversion_1", "updateversion_2", "userdisabled_1", "userdisabled_2", "hotfix" ]; const LOG_FUNCTION = info; +const BIN_SUFFIX = (IS_WIN ? ".exe" : ""); +const FILE_UPDATER_BIN = "updater" + (IS_MACOSX ? ".app" : BIN_SUFFIX); +const FILE_UPDATER_BIN_BAK = FILE_UPDATER_BIN + ".bak"; + var gURLData = URL_HOST + "/" + REL_PATH_DATA + "/"; var gTestTimeout = 240000; // 4 minutes var gTimeoutTimer; // The number of SimpleTest.executeSoon calls to perform when waiting on an // update window to close before giving up. const CLOSE_WINDOW_TIMEOUT_MAXCOUNT = 10; @@ -867,30 +872,75 @@ function verifyTestsRan() { let msg = "Checking if TESTS[" + i + "] test was performed... " + "callback function name = " + gCallback.name + ", " + "pageid = " + test.pageid; ok(test.ranTest, msg); } } /** + * Restore the updater that was backed up. This is called both in setupFiles + * and resetFiles. It is called in setupFiles before the backup is done in + * case the previous test failed. It is called in resetFiles to put things + * back to its original state. + */ +function resetUpdaterBackup() { + let baseAppDir = getAppBaseDir(); + let updater = baseAppDir.clone(); + let updaterBackup = baseAppDir.clone(); + updater.append(FILE_UPDATER_BIN); + updaterBackup.append(FILE_UPDATER_BIN_BAK); + if (updaterBackup.exists()) { + if (updater.exists()) { + updater.remove(true); + } + updaterBackup.moveTo(baseAppDir, FILE_UPDATER_BIN); + } +} + +/** * Creates a backup of files the tests need to modify so they can be restored to * the original file when the test has finished and then modifies the files. */ function setupFiles() { // Backup the updater-settings.ini file if it exists by moving it. let baseAppDir = getAppBaseDir(); let updateSettingsIni = baseAppDir.clone(); updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI); if (updateSettingsIni.exists()) { updateSettingsIni.moveTo(baseAppDir, FILE_UPDATE_SETTINGS_INI_BAK); } updateSettingsIni = baseAppDir.clone(); updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI); writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS); + + // Just in case the last test failed, try to reset. + resetUpdaterBackup(); + + // Move away the real updater + let updater = baseAppDir.clone(); + updater.append(FILE_UPDATER_BIN); + updater.moveTo(baseAppDir, FILE_UPDATER_BIN_BAK); + + // Move in the test only updater + let testUpdaterDir = Cc["@mozilla.org/file/directory_service;1"]. + getService(Ci.nsIProperties). + get("CurWorkD", Ci.nsILocalFile); + + let relPath = REL_PATH_DATA; + let pathParts = relPath.split("/"); + for (let i = 0; i < pathParts.length; ++i) { + testUpdaterDir.append(pathParts[i]); + } + + let testUpdater = testUpdaterDir.clone(); + testUpdater.append(FILE_UPDATER_BIN); + if (testUpdater.exists()) { + testUpdater.copyToFollowingLinks(baseAppDir, FILE_UPDATER_BIN); + } } /** * Sets the most common preferences used by tests to values used by the majority * of the tests and when necessary saves the preference's original values if * present so they can be set back to the original values when the test has * finished. */ @@ -973,16 +1023,17 @@ function resetFiles() { try { removeDirRecursive(updatedDir); } catch (e) { logTestInfo("Unable to remove directory. Path: " + updatedDir.path + ", Exception: " + e); } } + resetUpdaterBackup(); } /** * Resets the most common preferences used by tests to their original values. */ function resetPrefs() { if (gAppUpdateURL !== undefined) { Services.prefs.setCharPref(PREF_APP_UPDATE_URL_OVERRIDE, gAppUpdateURL);
--- a/toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in +++ b/toolkit/mozapps/update/updater/updater-xpcshell/Makefile.in @@ -1,16 +1,17 @@ # vim:set ts=8 sw=8 sts=8 noet: # 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/. # For changes here, also consider ../Makefile.in XPCSHELLTESTROOT = $(abspath $(DEPTH))/_tests/xpcshell/toolkit/mozapps/update/tests +MOCHITESTROOT = $(abspath $(DEPTH))/_tests/testing/mochitest/chrome/toolkit/mozapps/update/tests ifndef MOZ_PROFILE_GENERATE ifdef COMPILE_ENVIRONMENT INSTALL_TARGETS += xpcshell-updater xpcshell-updater_TARGET := libs xpcshell-updater_DEST := $(XPCSHELLTESTROOT)/data xpcshell-updater_FILES := $(DIST)/bin/updater-xpcshell$(BIN_SUFFIX) endif @@ -29,22 +30,28 @@ endif ifdef MOZ_WIDGET_GTK libs:: ../updater.png $(NSINSTALL) -D $(DIST)/bin/icons $(INSTALL) $(IFLAGS1) $^ $(DIST)/bin/icons endif libs:: ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) + # Copy for xpcshell tests $(NSINSTALL) -D $(XPCSHELLTESTROOT)/data/updater-xpcshell.app rsync -a -C --exclude '*.in' $(srcdir)/../macbuild/Contents $(XPCSHELLTESTROOT)/data/updater-xpcshell.app sed -e 's/%APP_NAME%/$(MOZ_APP_DISPLAYNAME)/' $(srcdir)/../macbuild/Contents/Resources/English.lproj/InfoPlist.strings.in | \ iconv -f UTF-8 -t UTF-16 > $(XPCSHELLTESTROOT)/data/updater-xpcshell.app/Contents/Resources/English.lproj/InfoPlist.strings $(NSINSTALL) -D $(XPCSHELLTESTROOT)/data/updater-xpcshell.app/Contents/MacOS/updater-xpcshell $(NSINSTALL) $(XPCSHELLTESTROOT)/data/updater-xpcshell $(XPCSHELLTESTROOT)/data/updater-xpcshell.app/Contents/MacOS rm -f $(XPCSHELLTESTROOT)/data/updater-xpcshell + rm -Rf $(XPCSHELLTESTROOT)/data/updater.app mv $(XPCSHELLTESTROOT)/data/updater-xpcshell.app $(XPCSHELLTESTROOT)/data/updater.app mv $(XPCSHELLTESTROOT)/data/updater.app/Contents/MacOS/updater-xpcshell $(XPCSHELLTESTROOT)/data/updater.app/Contents/MacOS/updater + + # Copy for mochitest chrome tests + rsync -a -C $(XPCSHELLTESTROOT)/data/updater.app $(MOCHITESTROOT)/data/updater.app else mv $(XPCSHELLTESTROOT)/data/updater-xpcshell$(BIN_SUFFIX) $(XPCSHELLTESTROOT)/data/updater$(BIN_SUFFIX) + cp $(XPCSHELLTESTROOT)/data/updater$(BIN_SUFFIX) $(MOCHITESTROOT)/data/updater$(BIN_SUFFIX) endif CXXFLAGS += $(MOZ_BZ2_CFLAGS)