Bug 500142 Create mozmill and mozmill-one make targets for build automation to use - tidy up and improvements. r=asuth
authorMark Banner <bugzilla@standard8.plus.com>
Fri, 24 Jul 2009 08:40:48 +0100
changeset 3126 5f48e2b67685124bc8120b30d3e054fd806d44d1
parent 3125 63a765629dc88fab2c4d8de839b6d5cb7ffb0eec
child 3127 a8ac240e2ba41ec27938565ff771db22a521b71a
push idunknown
push userunknown
push dateunknown
reviewersasuth
bugs500142
Bug 500142 Create mozmill and mozmill-one make targets for build automation to use - tidy up and improvements. r=asuth
mail/build.mk
mail/test/mozmill/runtest.py
mail/test/mozmill/runtestlist.py
--- a/mail/build.mk
+++ b/mail/build.mk
@@ -94,38 +94,38 @@ install::
 	@$(MAKE) -C mail/installer install
 
 source-package::
 	@$(MAKE) -C mail/installer source-package
 
 upload::
 	@$(MAKE) -C mail/installer upload
 
+ifdef ENABLE_TESTS
 # Instructions below this line are for mail/ specific tests.
 
 MOZMILLDIR=$(DEPTH)/mozilla/_tests/mozmill
 
-PROGRAM = $(DIST)
-
 ifneq (,$(filter mac 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/Contents/MacOS/
-PROGRAM := $(PROGRAM)thunderbird-bin$(BIN_SUFFIX)
+PROGRAM_LOCATION = ../../../$(DIST)/$(APP_NAME).app/Contents/MacOS/
+PROGRAM = $(PROGRAM_LOCATION)thunderbird-bin$(BIN_SUFFIX)
 else
 # Non-mac options
-PROGRAM = ../../../$(DIST)/bin/
-PROGRAM := $(PROGRAM)thunderbird$(BIN_SUFFIX)
+PROGRAM_LOCATION = ../../../$(DIST)/bin/
+PROGRAM = $(PROGRAM_LOCATION)thunderbird$(BIN_SUFFIX)
 endif
 
-ifdef ENABLE_TESTS
 mozmill::
 	cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) \
 	runtestlist.py --list=mozmilltests.list --binary=$(PROGRAM) \
-	--dir=$(topsrcdir)/mail/test/mozmill
+	--dir=$(topsrcdir)/mail/test/mozmill \
+	--default-profile=$(PROGRAM_LOCATION)/defaults/profile
 
 mozmill-one::
 	cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) runtest.py \
-	--test=$(topsrcdir)/mail/test/mozmill/$(SOLO_TEST) --binary=$(PROGRAM)
+	--test=$(topsrcdir)/mail/test/mozmill/$(SOLO_TEST) --binary=$(PROGRAM) \
+	--default-profile=$(PROGRAM_LOCATION)/defaults/profile
 endif
--- a/mail/test/mozmill/runtest.py
+++ b/mail/test/mozmill/runtest.py
@@ -197,44 +197,39 @@ class ThunderTestCLI(mozmill.CLI):
         """Parses the command line arguments and returns a runner instance."""
         (options, args) = self.parser.parse_args()
         self.options = options
         self.args = args
         if self.options.plugins is None:
             plugins = []
         else:
             plugins = self.options.plugins.split(',')
-            
+
         if self.options.test is not None:
             curdir = os.getcwd()
-            localprofile = os.path.join(curdir, self.options.test ,"profile")
+            localprofile = os.path.join(curdir, self.options.test, "profile")
+
             if os.path.isfile(localprofile):
-                profilefile = open(localprofile,"r")
+                profilefile = open(localprofile, "r")
                 nameinfile = profilefile.readline()
-                profilename = os.path.join(curdir, "profiles", nameinfile)
-                workingprofile = os.path.join(curdir, "work_profile", nameinfile)
-                if os.path.exists(workingprofile):
-                    shutil.rmtree(workingprofile)
-                shutil.copytree(profilename, workingprofile, False)
-                crea_new = False
-                def_profile = False
+                default_profile = os.path.join(curdir, "profiles", nameinfile)
             else:
-                def_profile = options.default_profile
-                workingprofile = options.profile
-                crea_new = options.create_new
+                default_profile = options.default_profile
 
         # We use a global as there appears to be no easy way of getting the
         # binary details into the profile without re-implementing what mozmill
         # gives us.
         global BINARY
         BINARY = self.options.binary
         print BINARY
 
-        profile = self.get_profile(def_profile, 
-                                   workingprofile, crea_new,
+        # We override profile in ThunderbirdTestProfile, so no point in setting
+        # it here.
+        profile = self.get_profile(default_profile, 
+                                   None, True,
                                    plugins=plugins)
         runner = self.get_runner(binary=self.options.binary, 
                                  profile=profile)
         
         return runner
 
 
 TEST_RESULTS = []
--- a/mail/test/mozmill/runtestlist.py
+++ b/mail/test/mozmill/runtestlist.py
@@ -52,16 +52,21 @@ class RunTestListOptions(optparse.Option
         optparse.OptionParser.__init__(self, **kwargs)
         defaults = {}
 
         self.add_option("--binary",
                         action = "store", type = "string", dest = "binary",
                         help = "Binary to be run")
         defaults["binary"] = ""
 
+        self.add_option("--default-profile",
+                        action = "store", type = "string", dest = "default_profile",
+                        help = "Location of profile to copy from. May be overriden by individual test setups.")
+        defaults["default_profile"] = ""
+
         self.add_option("--list",
                         action = "store", type = "string", dest = "list",
                         help = "List of tests to be run")
         defaults["list"] = ""
 
         self.add_option("--dir",
                         action = "store", type = "string", dest = "dir",
                         help = "Directory of the tests, leave blank for current directory")
@@ -78,34 +83,35 @@ All arguments must be specified.
 log = logging.getLogger()
 handler = logging.StreamHandler(sys.stdout)
 log.setLevel(logging.INFO)
 log.addHandler(handler)
 
 parser = RunTestListOptions()
 options, args = parser.parse_args()
 
-if options.binary == "" or options.list == "":
+if options.binary == "" or options.list == "" or options.default_profile == "":
     parser.print_help()
     sys.exit(1)
 
 totalTestErrors = 0
 totalTestPasses = 0
 totalDirectories = 0
 
 f = open(options.list, 'rt')
 for directory in f:
     log.info("INFO | (runtestlist.py) | Running directory: %s",
              directory.rstrip())
     if options.dir != "":
         testDirectory = os.path.join(options.dir, directory.rstrip())
     else:
         testDirectory = directory.rstrip()
-    args = ["python", "runtest.py", "-t", testDirectory, "--binary",
-                   options.binary]
+    args = ["python", "runtest.py", "-t", testDirectory,
+            "--binary", options.binary,
+            "--default-profile", options.default_profile]
     print args
     outputPipe = subprocess.PIPE
 
     proc = subprocess.Popen(args, cwd=SCRIPT_DIRECTORY, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
 
     testErrors = 0
     testPasses = 0