Bug 506202 Hook up mozmill tests to make package-tests and support running packaged test style. r=asuth,gozer. a=Standard8 for checkin to CLOSED TREE as this is build-config/test only and allows work on the new try server to get it nearer completion
--- a/Makefile.in
+++ b/Makefile.in
@@ -74,20 +74,21 @@ config.status: $(topsrcdir)/configure
default export libs clean realclean distclean alldep maybe_clobber_profiledbuild uploadsymbols all::
$(MAKE) -C mozilla $@
ifdef ENABLE_TESTS
check \
mochitest mochitest-plain mochitest-chrome mochitest-browser-chrome mochitest-a11y \
reftest crashtest \
-xpcshell-tests \
-package-tests::
+xpcshell-tests::
$(MAKE) -C mozilla $@
-else
+endif
+
+ifndef MOZ_THUNDERBIRD
package-tests::
$(MAKE) -C mozilla $@
endif
# http://bugzilla.mozilla.org/show_bug.cgi?id=450485
MAKE_SYM_STORE_PATH=dist/bin
ifeq ($(OS_ARCH),Darwin)
ifdef UNIVERSAL_BINARY
--- a/build/macosx/universal/flight.mk
+++ b/build/macosx/universal/flight.mk
@@ -125,14 +125,18 @@ endif
# automation.py differs because it hardcodes a path to
# dist/bin. It doesn't matter which one we use.
if test -d $(DIST_ARCH_1)/test-package-stage -a \
-d $(DIST_ARCH_2)/test-package-stage; then \
cp $(DIST_ARCH_1)/test-package-stage/mochitest/automation.py \
$(DIST_ARCH_2)/test-package-stage/mochitest/; \
cp $(DIST_ARCH_1)/test-package-stage/reftest/automation.py \
$(DIST_ARCH_2)/test-package-stage/reftest/; \
+ if test -e $(DIST_ARCH_1)/test-package-stage/mozmill/automation.py; then \
+ cp $(DIST_ARCH_1)/test-package-stage/mozmill/automation.py \
+ $(DIST_ARCH_2)/test-package-stage/mozmill/; \
+ fi; \
$(TOPSRCDIR)/mozilla/build/macosx/universal/unify \
--unify-with-sort "all-test-dirs\.list$$" \
$(DIST_ARCH_1)/test-package-stage \
$(DIST_ARCH_2)/test-package-stage \
$(DIST_UNI)/test-package-stage; \
fi
--- a/mail/build.mk
+++ b/mail/build.mk
@@ -90,43 +90,14 @@ install::
source-package::
@$(MAKE) -C mail/installer source-package
upload::
@$(MAKE) -C mail/installer upload
ifdef ENABLE_TESTS
-# Additional mailnews targets to call automated test suites
-include $(topsrcdir)/mailnews/testsuite-targets.mk
-
-# Instructions below this line are for mail/ specific tests.
-
-MOZMILLDIR=$(DEPTH)/mozilla/_tests/mozmill
-
-ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
-# Mac options
-APP_NAME = $(MOZ_APP_DISPLAYNAME)
-ifdef MOZ_DEBUG
-APP_NAME := $(APP_NAME)Debug
-endif
-PROGRAM = ../../../$(DIST)/$(APP_NAME).app/
+include $(srcdir)/mail/testsuite-targets.mk
else
-# Non-mac options
-PROGRAM = ../../../$(DIST)/bin/thunderbird$(BIN_SUFFIX)
+package-tests::
endif
-mozmill::
- cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) \
- runtestlist.py --list=mozmilltests.list --binary=$(PROGRAM) \
- --dir=$(call core_abspath,$(topsrcdir))/mail/test/mozmill \
- --symbols-path=$(call core_abspath,$(DIST)/crashreporter-symbols) \
- $(MOZMILL_EXTRA)
-
-mozmill-one::
- cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) runtest.py \
- --test=$(call core_abspath,$(topsrcdir))/mail/test/mozmill/$(SOLO_TEST) \
- --binary=$(PROGRAM) \
- --symbols-path=$(call core_abspath,$(DIST)/crashreporter-symbols) \
- $(MOZMILL_EXTRA)
-endif # ENABLE_TESTS
-
endif # COMM_BUILD
--- a/mail/test/mozmill/Makefile.in
+++ b/mail/test/mozmill/Makefile.in
@@ -58,17 +58,29 @@ include $(MOZILLA_DIR)/build/automation-
$(srcdir)/mozmilltests.list \
automation.py \
$(MOZILLA_DIR)/build/automationutils.py \
$(NULL)
GARBAGE += automation.py
$(_DEST_DIR):
- echo $(_HARNESS_FILES)
$(NSINSTALL) -D $@
$(_HARNESS_FILES): $(_DEST_DIR)
# Copy the mozmill bits to $(_DEST_DIR)
libs:: $(_HARNESS_FILES)
echo $(_HARNESS_FILES)
$(INSTALL) $(_HARNESS_FILES) $(_DEST_DIR)
+
+# Copy the mailnews and mail resources that we require.
+libs::
+ $(INSTALL) $(topsrcdir)/mailnews/test/resources/* $(MOZDEPTH)/_tests/mozmill/resources
+ $(INSTALL) $(topsrcdir)/mailnews/test/fakeserver/* $(MOZDEPTH)/_tests/mozmill/resources
+ $(INSTALL) $(topsrcdir)/mail/base/test/unit/resources/* $(MOZDEPTH)/_tests/mozmill/resources
+
+PKG_STAGE = $(DIST)/test-package-stage
+
+stage-package:
+ $(NSINSTALL) -D $(PKG_STAGE)/mozmill/
+ @(cd $(topsrcdir)/mail/test/mozmill && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/ && tar -xf -)
+ @(cd $(MOZDEPTH)/_tests/mozmill && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mozmill/ && tar -xf -)
old mode 100644
new mode 100755
--- a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
@@ -57,16 +57,23 @@ const RELATIVE_ROOT = '../shared-modules
// we need window-helpers for augment_controller
const MODULE_REQUIRES = ['window-helpers'];
const nsMsgViewIndex_None = 0xffffffff;
Cu.import('resource:///modules/MailUtils.js');
Cu.import('resource:///modules/MailConsts.js');
Cu.import('resource:///modules/mailViewManager.js');
+const FILE_LOAD_PATHS = [
+ "../resources",
+ "../../../../mailnews/test/resources",
+ "../../../../mail/base/test/unit/resources",
+ "../../../../mailnews/test/fakeserver"
+];
+
/**
* List of keys not to export via installInto; values do not matter, we just
* use true.
*/
const DO_NOT_EXPORT = {
// magic globals
MODULE_NAME: true, DO_NOT_EXPORT: true, installInto: true,
// imported modules
@@ -134,18 +141,17 @@ function setupModule() {
throw new Error(aMsg);
},
do_check_eq: function() {},
do_check_neq: function() {},
};
// The xpcshell test resources assume they are loaded into a single global
// namespace, so we need to help them out to maintain their delusion.
- load_via_src_path('mailnews/test/resources/logHelper.js',
- testHelperModule);
+ load_via_src_path('logHelper.js', testHelperModule);
mark_action = testHelperModule.mark_action;
mark_failure = testHelperModule.mark_failure;
// Hook-up logHelper to the mozmill event system...
let curTestFile = null;
frame.events.addListener("setTest", function(obj) {
if (obj.filename != curTestFile) {
testHelperModule.mark_test_start(obj.filename);
@@ -154,30 +160,24 @@ function setupModule() {
testHelperModule.mark_sub_test_start(obj.name);
});
frame.events.addListener("fail", function(obj) {
testHelperModule._xpcshellLogger.info(
testHelperModule._testLoggerActiveContext,
new testHelperModule._Failure(obj.exception.message, obj.exception));
});
- load_via_src_path('mailnews/test/resources/asyncTestUtils.js',
- testHelperModule);
- load_via_src_path('mailnews/test/resources/messageGenerator.js',
- testHelperModule);
- load_via_src_path('mailnews/test/resources/messageModifier.js',
- testHelperModule);
- load_via_src_path('mailnews/test/resources/messageInjection.js',
- testHelperModule);
- load_via_src_path('mail/base/test/unit/resources/viewWrapperTestUtils.js',
- testHelperModule);
+ load_via_src_path('asyncTestUtils.js', testHelperModule);
+ load_via_src_path('messageGenerator.js', testHelperModule);
+ load_via_src_path('messageModifier.js', testHelperModule);
+ load_via_src_path('messageInjection.js', testHelperModule);
+ load_via_src_path('viewWrapperTestUtils.js', testHelperModule);
// provide super helpful folder event info (when logHelper cares)
- load_via_src_path('mailnews/test/resources/folderEventLogHelper.js',
- testHelperModule);
+ load_via_src_path('folderEventLogHelper.js', testHelperModule);
testHelperModule.registerFolderEventLogHelper();
// messageInjection wants a gMessageGenerator (and so do we)
msgGen = new testHelperModule.MessageGenerator();
testHelperModule.gMessageGenerator = msgGen;
testHelperModule.gMessageScenarioFactory =
new testHelperModule.MessageScenarioFactory(msgGen);
@@ -2483,24 +2483,40 @@ var delete_message_set;
* @return An object that serves as the global scope for the loaded file.
*/
function load_via_src_path(aPath, aModule) {
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Ci.mozIJSSubScriptLoader);
let ioService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
- let srcPath = os.abspath("../../../..",os.getFileForPath( __file__));
- let fullPath = os.abspath(aPath, os.getFileForPath(srcPath));
+ let thisFilePath = os.getFileForPath(__file__);
+
+ for (let i = 0; i < FILE_LOAD_PATHS.length; ++i) {
+ let srcPath = os.abspath(FILE_LOAD_PATHS[i], thisFilePath);
+ let fullPath = os.abspath(aPath, os.getFileForPath(srcPath));
+
+ let file = Cc["@mozilla.org/file/local;1"]
+ .createInstance(Ci.nsILocalFile);
+ file.initWithPath(fullPath);
- let file = Cc["@mozilla.org/file/local;1"]
- .createInstance(Ci.nsILocalFile);
- file.initWithPath(fullPath);
- let uri = ioService.newFileURI(file).spec;
- loader.loadSubScript(uri, aModule);
+ if (file.exists()) {
+ try {
+ let uri = ioService.newFileURI(file).spec;
+ loader.loadSubScript(uri, aModule);
+ return;
+ }
+ catch (ex) {
+ throw new Error("Unable to load file: " + fullPath + " exception: " + ex);
+ }
+ }
+ }
+
+ // If we've got this far, then we weren't successful, fail out.
+ throw new Error("Could not find " + aModule + " in available paths");
}
function assert_equals(a, b, comment)
{
if (!comment)
comment = "a != b";
assert_true(a == b, comment + ": '"+ a + "' != '" + b + "'.");
}
--- a/mail/test/mozmill/shared-modules/test-nntp-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-nntp-helpers.js
@@ -84,18 +84,17 @@ function setupModule() {
// fake some xpcshell stuff
_TEST_FILE: ["mozmill"],
do_throw: function(aMsg) {
throw new Error(aMsg);
},
do_check_eq: function() {},
do_check_neq: function() {},
};
- folderDisplayHelper.load_via_src_path("mailnews/test/fakeserver/nntpd.js",
- testHelperModule);
+ folderDisplayHelper.load_via_src_path("nntpd.js", testHelperModule);
}
function installInto(module) {
setupModule();
// Now copy helper functions
module.setupNNTPDaemon = setupNNTPDaemon;
module.NNTP_PORT = NNTP_PORT;
new file mode 100644
--- /dev/null
+++ b/mail/testsuite-targets.mk
@@ -0,0 +1,58 @@
+# Additional mailnews targets to call automated test suites
+include $(topsrcdir)/mailnews/testsuite-targets.mk
+
+# Instructions below this line are for mail/ specific tests.
+
+MOZMILLDIR=$(DEPTH)/mozilla/_tests/mozmill
+
+ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
+# Mac options
+APP_NAME = $(MOZ_APP_DISPLAYNAME)
+ifdef MOZ_DEBUG
+APP_NAME := $(APP_NAME)Debug
+endif
+PROGRAM = ../../../$(DIST)/$(APP_NAME).app/
+else
+# Non-mac options
+PROGRAM = ../../../$(DIST)/bin/thunderbird$(BIN_SUFFIX)
+endif
+
+mozmill::
+ cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) \
+ runtestlist.py --list=mozmilltests.list --binary=$(PROGRAM) \
+ --dir=$(call core_abspath,$(topsrcdir))/mail/test/mozmill \
+ --symbols-path=$(call core_abspath,$(DIST)/crashreporter-symbols) \
+ $(MOZMILL_EXTRA)
+
+mozmill-one::
+ cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) runtest.py \
+ --test=$(call core_abspath,$(topsrcdir))/mail/test/mozmill/$(SOLO_TEST) \
+ --binary=$(PROGRAM) \
+ --symbols-path=$(call core_abspath,$(DIST)/crashreporter-symbols) \
+ $(MOZMILL_EXTRA)
+
+# XXX Really we should be re-using the mozilla-central
+# testing/testsuite-targets.mk. However, to get mozmill tests packaged and
+# running, we've just implemented what we need here for now.
+ifndef UNIVERSAL_BINARY
+PKG_STAGE = $(DIST)/test-package-stage
+package-tests:: stage-mozmill
+else
+# This staging area has been built for us by universal/flight.mk
+PKG_STAGE = $(DIST)/universal/test-package-stage
+endif
+
+package-tests::
+ $(NSINSTALL) -D $(DIST)/$(PKG_PATH)
+ @rm -f "$(DIST)/$(PKG_PATH)$(TEST_PACKAGE)"
+ cd $(PKG_STAGE) && \
+ zip -r9D "$(call core_abspath,$(DIST)/$(PKG_PATH)$(TEST_PACKAGE))" *
+
+make-stage-dir:
+ rm -rf $(PKG_STAGE) && $(NSINSTALL) -D $(PKG_STAGE) && $(NSINSTALL) -D $(PKG_STAGE)/bin && $(NSINSTALL) -D $(PKG_STAGE)/bin/components && $(NSINSTALL) -D $(PKG_STAGE)/certs
+
+stage-mozmill: make-stage-dir
+ $(MAKE) -C $(DEPTH)/mail/test/mozmill stage-package
+
+.PHONY: \
+ package-tests make-stage-dir stage-mozmill