Bug 421611 - Need to be able to run tests on arbitrary build - add packaging bits for xpcshell. r=bsmedberg
authorTed Mielczarek <ted.mielczarek@gmail.com>
Sat, 21 Mar 2009 11:20:00 -0400
changeset 26447 99930ad81298752686082643f01358c474e32dc7
parent 26446 a17552ca8f97ff788325cbfa17b35aeb0523a907
child 26448 a22f6eddb038bbe80454a03dbb1c9ac8189d2140
push idunknown
push userunknown
push dateunknown
reviewersbsmedberg
bugs421611
milestone1.9.2a1pre
Bug 421611 - Need to be able to run tests on arbitrary build - add packaging bits for xpcshell. r=bsmedberg
config/rules.mk
intl/locale/src/unix/tests/Makefile.in
intl/strres/tests/397093.properties
intl/strres/tests/Makefile.in
intl/strres/tests/strres.properties
intl/strres/tests/unit/397093.properties
intl/strres/tests/unit/strres.properties
intl/strres/tests/unit/test_bug378839.js
intl/strres/tests/unit/test_bug397093.js
js/src/config/rules.mk
modules/plugin/test/unit/test_bug455213.js
testing/mochitest/Makefile.in
testing/testsuite-targets.mk
testing/xpcshell/Makefile.in
testing/xpcshell/runxpcshelltests.py
toolkit/mozapps/update/test/unit/head_update.js
toolkit/mozapps/update/test/unit/test_0110_general.js
uriloader/exthandler/tests/Makefile.in
uriloader/exthandler/tests/unit/test_punycodeURIs.js
xpcom/tests/Makefile.in
xpcom/tests/unit/test_nsIProcess.js
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -142,46 +142,46 @@ define _INSTALL_TESTS
 $(TEST_INSTALLER) $(wildcard $(srcdir)/$(dir)/*) $(testxpcobjdir)/$(MODULE)/$(dir)
 
 endef # do not remove the blank line!
 
 SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
 
 libs::
 	$(foreach dir,$(XPCSHELL_TESTS),$(_INSTALL_TESTS))
+	$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl \
+          $(testxpcobjdir)/all-test-dirs.list \
+          $(addprefix $(MODULE)/,$(XPCSHELL_TESTS))
 
 testxpcsrcdir = $(topsrcdir)/testing/xpcshell
 
 # Execute all tests in the $(XPCSHELL_TESTS) directories.
 check::
 	$(PYTHON) -u \
           $(testxpcsrcdir)/runxpcshelltests.py \
           $(DIST)/bin/xpcshell \
-          $(topsrcdir) \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 # Execute a single test, specified in $(SOLO_FILE), but don't automatically
 # start the test. Instead, present the xpcshell prompt so the user can
 # attach a debugger and then start the test.
 check-interactive::
 	$(PYTHON) \
           $(testxpcsrcdir)/runxpcshelltests.py \
           --test=$(SOLO_FILE) \
           --interactive \
           $(DIST)/bin/xpcshell \
-          $(topsrcdir) \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 # Execute a single test, specified in $(SOLO_FILE)
 check-one::
 	$(PYTHON) \
           $(testxpcsrcdir)/runxpcshelltests.py \
           --test=$(SOLO_FILE) \
           $(DIST)/bin/xpcshell \
-          $(topsrcdir) \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 endif # XPCSHELL_TESTS
 
 ifdef CPP_UNIT_TESTS
 
 # Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
 # through TestHarness.h, by modifying the list of includes and the libs against
--- a/intl/locale/src/unix/tests/Makefile.in
+++ b/intl/locale/src/unix/tests/Makefile.in
@@ -30,17 +30,17 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
-DEPTH		= ../../../../../
+DEPTH		= ../../../../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE          = test_intl_locale_unix
 XPCSHELL_TESTS  = unit
--- a/intl/strres/tests/Makefile.in
+++ b/intl/strres/tests/Makefile.in
@@ -41,21 +41,9 @@ srcdir		= @srcdir@
 VPATH		= @srcdir@
 
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		 = test_intl_strres
 
 XPCSHELL_TESTS	 = unit
 
-EXPORT_RESOURCE	= \
-		$(srcdir)/strres.properties \
-		$(srcdir)/397093.properties \
-		$(NULL)
-
 include $(topsrcdir)/config/rules.mk
-
-libs::
-	$(INSTALL) $(EXPORT_RESOURCE) $(DIST)/bin/res
-
-install::
-	$(SYSINSTALL) $(IFLAGS1) $(EXPORT_RESOURCE) $(DESTDIR)$(mozappdir)/res
-
rename from intl/strres/tests/397093.properties
rename to intl/strres/tests/unit/397093.properties
rename from intl/strres/tests/strres.properties
rename to intl/strres/tests/unit/strres.properties
--- a/intl/strres/tests/unit/test_bug378839.js
+++ b/intl/strres/tests/unit/test_bug378839.js
@@ -26,18 +26,21 @@ const name_hello = "hello";
 const var_hello = "World";
 const value_hello = "Hello World"; // tests formatStringFromName with parameter
 
 
 function run_test() {
     var StringBundle = 
 	Components.classes["@mozilla.org/intl/stringbundle;1"]
 	 .getService(Components.interfaces.nsIStringBundleService);
+    var ios = Components.classes["@mozilla.org/network/io-service;1"]
+	 .getService(Components.interfaces.nsIIOService);
+    var bundleURI = ios.newFileURI(do_get_file("strres.properties"));
 
-    var bundle = StringBundle.createBundle("resource://gre/res/strres.properties");
+    var bundle = StringBundle.createBundle(bundleURI.spec);
 
     var bundle_file = bundle.GetStringFromName(name_file);
     do_check_eq(bundle_file, value_file);
 
     var bundle_loyal = bundle.GetStringFromName(name_loyal);
     do_check_eq(bundle_loyal, value_loyal);
 
     var bundle_trout = bundle.GetStringFromName(name_trout);
--- a/intl/strres/tests/unit/test_bug397093.js
+++ b/intl/strres/tests/unit/test_bug397093.js
@@ -13,18 +13,21 @@ const value_utf8 = "";
 const name_latin1 = "latin1";
 const value_latin1 = "";
 
 
 function run_test() {
     var StringBundle = 
 	Components.classes["@mozilla.org/intl/stringbundle;1"]
 	 .getService(Components.interfaces.nsIStringBundleService);
+    var ios = Components.classes["@mozilla.org/network/io-service;1"]
+	 .getService(Components.interfaces.nsIIOService);
+    var bundleURI = ios.newFileURI(do_get_file("397093.properties"));
 
-    var bundle = StringBundle.createBundle("resource://gre/res/397093.properties");
+    var bundle = StringBundle.createBundle(bundleURI.spec);
     
     var bundle_ascii="", bundle_utf8="", bundle_latin1="";
     try {
 	bundle_ascii = bundle.GetStringFromName(name_ascii);
     } catch(e) {}
     do_check_eq(bundle_ascii, value_ascii);
 
     try {
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -142,46 +142,46 @@ define _INSTALL_TESTS
 $(TEST_INSTALLER) $(wildcard $(srcdir)/$(dir)/*) $(testxpcobjdir)/$(MODULE)/$(dir)
 
 endef # do not remove the blank line!
 
 SOLO_FILE ?= $(error Specify a test filename in SOLO_FILE when using check-interactive or check-one)
 
 libs::
 	$(foreach dir,$(XPCSHELL_TESTS),$(_INSTALL_TESTS))
+	$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/build-list.pl \
+          $(testxpcobjdir)/all-test-dirs.list \
+          $(addprefix $(MODULE)/,$(XPCSHELL_TESTS))
 
 testxpcsrcdir = $(topsrcdir)/testing/xpcshell
 
 # Execute all tests in the $(XPCSHELL_TESTS) directories.
 check::
 	$(PYTHON) -u \
           $(testxpcsrcdir)/runxpcshelltests.py \
           $(DIST)/bin/xpcshell \
-          $(topsrcdir) \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 # Execute a single test, specified in $(SOLO_FILE), but don't automatically
 # start the test. Instead, present the xpcshell prompt so the user can
 # attach a debugger and then start the test.
 check-interactive::
 	$(PYTHON) \
           $(testxpcsrcdir)/runxpcshelltests.py \
           --test=$(SOLO_FILE) \
           --interactive \
           $(DIST)/bin/xpcshell \
-          $(topsrcdir) \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 # Execute a single test, specified in $(SOLO_FILE)
 check-one::
 	$(PYTHON) \
           $(testxpcsrcdir)/runxpcshelltests.py \
           --test=$(SOLO_FILE) \
           $(DIST)/bin/xpcshell \
-          $(topsrcdir) \
           $(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
 
 endif # XPCSHELL_TESTS
 
 ifdef CPP_UNIT_TESTS
 
 # Compile the tests to $(DIST)/bin.  Make lots of niceties available by default
 # through TestHarness.h, by modifying the list of includes and the libs against
--- a/modules/plugin/test/unit/test_bug455213.js
+++ b/modules/plugin/test/unit/test_bug455213.js
@@ -50,17 +50,17 @@ if ("@mozilla.org/windows-registry-key;1
 var gProfD;
 var gDirSvc = Cc["@mozilla.org/file/directory_service;1"].
              getService(Ci.nsIProperties);
 
 // Creates a fake profile folder that the pluginhost will read our crafted
 // pluginreg.dat from
 function createProfileFolder() {
   // Remove '/unit/*.js'.
-  gProfD = __LOCATION__.parent.parent;
+  gProfD = do_get_cwd();
   gProfD.append("profile");
   
   if (gProfD.exists())
     gProfD.remove(true);
   gProfD.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
   
   var dirProvider = {
     getFile: function(prop, persistent) {
--- a/testing/mochitest/Makefile.in
+++ b/testing/mochitest/Makefile.in
@@ -112,16 +112,16 @@ else
 TEST_HARNESS_PLUGINS := \
   $(DLL_PREFIX)nptest$(DLL_SUFFIX)
 endif
 
 # Rules for staging the necessary harness bits for a test package
 PKG_STAGE = $(DIST)/test-package-stage
 
 stage-package:
-	$(NSINSTALL) -D $(PKG_STAGE)/mochitest && $(NSINSTALL) -D $(PKG_STAGE)/plugins
+	$(NSINSTALL) -D $(PKG_STAGE)/mochitest && $(NSINSTALL) -D $(PKG_STAGE)/bin/plugins
 	@(cd $(DEPTH)/_tests/testing/mochitest/ && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/mochitest && tar -xf -)
 	@(cd $(DIST)/bin && tar $(TAR_CREATE_FLAGS) - $(TEST_HARNESS_BINS)) | (cd $(PKG_STAGE)/bin && tar -xf -)
 	@(cd $(DIST)/bin/components && tar $(TAR_CREATE_FLAGS) - $(TEST_HARNESS_COMPONENTS)) | (cd $(PKG_STAGE)/bin/components && tar -xf -)
 	@(cd $(topsrcdir)/build/pgo/certs && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/certs && tar -xf -)
 ifdef MOZ_PLUGINS
-	@(cd $(DIST)/bin/plugins && tar $(TAR_CREATE_FLAGS) - $(TEST_HARNESS_PLUGINS)) | (cd $(PKG_STAGE)/plugins && tar -xf -)
+	@(cd $(DIST)/bin/plugins && tar $(TAR_CREATE_FLAGS) - $(TEST_HARNESS_PLUGINS)) | (cd $(PKG_STAGE)/bin/plugins && tar -xf -)
 endif
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -80,22 +80,26 @@ crashtest:
 	$(call RUN_REFTEST,$(topsrcdir)/testing/crashtest/crashtests.list)
 	$(CHECK_TEST_ERROR)
 
 # Package up the tests and test harnesses
 include $(topsrcdir)/toolkit/mozapps/installer/package-name.mk
 
 PKG_STAGE = $(DIST)/test-package-stage
 
-package-tests: stage-mochitest stage-reftest
+package-tests: stage-mochitest stage-reftest stage-xpcshell
 	@(cd $(PKG_STAGE) && tar $(TAR_CREATE_FLAGS) - *) | bzip2 -f > $(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-mochitest: make-stage-dir
 	$(MAKE) -C $(DEPTH)/testing/mochitest stage-package
 
 stage-reftest: make-stage-dir
 	$(MAKE) -C $(DEPTH)/layout/tools/reftest stage-package
 
+stage-xpcshell: make-stage-dir
+	$(MAKE) -C $(DEPTH)/testing/xpcshell stage-package
+
 .PHONY: mochitest mochitest-plain mochitest-chrome mochitest-a11y \
-  package-tests make-stage-dir stage-mochitest
+  reftest crashtest package-tests make-stage-dir stage-mochitest \
+  stage-reftest stage-xpcshell
--- a/testing/xpcshell/Makefile.in
+++ b/testing/xpcshell/Makefile.in
@@ -47,8 +47,30 @@ MODULE		= testing_xpcshell
 
 # Here's how you let the build system know there are tests in the
 # "example" folder:
 ifdef ENABLE_TESTS
 DIRS  += example
 endif
 
 include $(topsrcdir)/config/rules.mk
+
+# Harness files from the srcdir
+TEST_HARNESS_FILES := \
+  runxpcshelltests.py \
+  head.js \
+  tail.js \
+  $(NULL)
+
+# Components / typelibs that don't get packaged with
+# the build, but that we need for the test harness.
+TEST_HARNESS_COMPONENTS := \
+  httpd.js \
+  $(NULL)
+
+# Rules for staging the necessary harness bits for a test package
+PKG_STAGE = $(DIST)/test-package-stage
+
+stage-package:
+	$(NSINSTALL) -D $(PKG_STAGE)/xpcshell/tests
+	@(cd $(srcdir) && tar $(TAR_CREATE_FLAGS) - $(TEST_HARNESS_FILES)) | (cd $(PKG_STAGE)/xpcshell && tar -xf -)
+	@(cd $(DEPTH)/_tests/xpcshell/ && tar $(TAR_CREATE_FLAGS) - *) | (cd $(PKG_STAGE)/xpcshell/tests && tar -xf -)
+	@(cd $(DIST)/bin/components && tar $(TAR_CREATE_FLAGS) - $(TEST_HARNESS_COMPONENTS)) | (cd $(PKG_STAGE)/bin/components && tar -xf -)
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -36,34 +36,61 @@
 #
 # ***** END LICENSE BLOCK ***** */
 
 import sys, os, os.path
 from glob import glob
 from optparse import OptionParser
 from subprocess import Popen, PIPE, STDOUT
 
-def runTests(xpcshell, topsrcdir, testdirs, xrePath=None, testFile=None,
-             interactive=False):
+def readManifest(manifest):
+  """Given a manifest file containing a list of test directories,
+  return a list of absolute paths to the directories contained within."""
+  manifestdir = os.path.dirname(manifest)
+  testdirs = []
+  try:
+    f = open(manifest, "r")
+    for line in f:
+      dir = line.rstrip()
+      path = os.path.join(manifestdir, dir)
+      if os.path.isdir(path):
+        testdirs.append(path)
+    f.close()
+  except:
+    pass # just eat exceptions
+  return testdirs
+
+def runTests(xpcshell, testdirs=[], xrePath=None, testFile=None,
+             manifest=None, interactive=False, keepGoing=False):
   """Run the tests in |testdirs| using the |xpcshell| executable.
-  If provided, |xrePath| is the path to the XRE to use. If provided,
-  |testFile| indicates a single test to run. |interactive|, if set to True,
-  indicates to provide an xpcshell prompt instead of automatically executing
-  the test."""
+  |xrePath|, if provided, is the path to the XRE to use.
+  |testFile|, if provided, indicates a single test to run.
+  |manifeest|, if provided, is a file containing a list of
+    test directories to run.
+  |interactive|, if set to True, indicates to provide an xpcshell prompt
+    instead of automatically executing  the test.
+  |keepGoing|, if set to True, indicates that if a test fails
+    execution should continue."""
   testharnessdir = os.path.dirname(os.path.abspath(__file__))
   xpcshell = os.path.abspath(xpcshell)
   # we assume that httpd.js lives in components/ relative to xpcshell
   httpdJSPath = os.path.join(os.path.dirname(xpcshell), "components", "httpd.js").replace("\\", "/");
 
   env = dict(os.environ)
   # Make assertions fatal
   env["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
 
+  if not testdirs and not manifest:
+    # nothing to test!
+    raise Exception("No test dirs or test manifest specified!")
+
   if xrePath is None:
     xrePath = os.path.dirname(xpcshell)
+  else:
+    xrePath = os.path.abspath(xrePath)
   if sys.platform == 'win32':
     env["PATH"] = env["PATH"] + ";" + xrePath
   elif sys.platform == 'osx':
     env["DYLD_LIBRARY_PATH"] = xrePath
   else: # unix or linux?
     env["LD_LIBRARY_PATH"] = xrePath
   args = [xpcshell, '-g', xrePath, '-j', '-s']
 
@@ -77,16 +104,21 @@ def runTests(xpcshell, topsrcdir, testdi
   # testdir/filename. This is for convenience when there's only one
   # test dir.
   singleDir = None
   if testFile and testFile.find('/') != -1:
     # directory was specified
     bits = testFile.split('/', 1)
     singleDir = bits[0]
     testFile = bits[1]
+
+  if manifest is not None:
+    testdirs = readManifest(os.path.abspath(manifest))
+
+  success = True
   for testdir in testdirs:
     if singleDir and singleDir != os.path.basename(testdir):
       continue
     testdir = os.path.abspath(testdir)
 
     # get the list of head and tail files from the directory
     testheadfiles = []
     for f in sorted(glob(os.path.join(testdir, "head_*.js"))):
@@ -111,55 +143,70 @@ def runTests(xpcshell, topsrcdir, testdi
       interactiveargs = []
       if interactive:
         pstdout = None
         pstderr = None
         interactiveargs = ['-e', 'print("To start the test, type _execute_test();")', '-i']
       full_args = args + headfiles + testheadfiles \
                   + ['-f', test] \
                   + tailfiles + testtailfiles + interactiveargs
-      #print "args: %s" % full_args
       proc = Popen(full_args, stdout=pstdout, stderr=pstderr,
                    env=env, cwd=testdir)
       stdout, stderr = proc.communicate()
 
       if interactive:
         # not sure what else to do here...
         return True
 
       if proc.returncode != 0 or stdout.find("*** PASS") == -1:
         print """TEST-UNEXPECTED-FAIL | %s | test failed, see log
   %s.log:
   >>>>>>>
   %s
   <<<<<<<""" % (test, test, stdout)
-        return False
-
-      print "TEST-PASS | %s | all tests passed" % test
-  return True
+        if not keepGoing:
+          return False
+        success = False
+      else:
+        print "TEST-PASS | %s | all tests passed" % test
+  return success
 
 def main():
   """Process command line arguments and call runTests() to do the real work."""
   parser = OptionParser()
   parser.add_option("--xre-path",
                     action="store", type="string", dest="xrePath", default=None,
                     help="absolute path to directory containing XRE (probably xulrunner)")
   parser.add_option("--test",
-                    action="store", type="string", dest="testFile", default=None,
-                    help="single test filename to test")
+                    action="store", type="string", dest="testFile",
+                    default=None, help="single test filename to test")
   parser.add_option("--interactive",
                     action="store_true", dest="interactive", default=False,
                     help="don't automatically run tests, drop to an xpcshell prompt")
+  parser.add_option("--keep-going",
+                    action="store_true", dest="keepGoing", default=False,
+                    help="continue running tests past the first failure")
+  parser.add_option("--manifest",
+                    action="store", type="string", dest="manifest",
+                    default=None, help="Manifest of test directories to use")
   options, args = parser.parse_args()
 
-  if len(args) < 3:
-    print >>sys.stderr, "Usage: %s <path to xpcshell> <topsrcdir> <test dirs>" % sys.argv[0]
+  if len(args) < 2 and options.manifest is None or \
+     (len(args) < 1 and options.manifest is not None):
+    print >>sys.stderr, """Usage: %s <path to xpcshell> <test dirs>
+  or: %s --manifest=test.manifest <path to xpcshell>""" % (sys.argv[0],
+                                                           sys.argv[0])
     sys.exit(1)
 
   if options.interactive and not options.testFile:
     print >>sys.stderr, "Error: You must specify a test filename in interactive mode!"
     sys.exit(1)
 
-  if not runTests(args[0], args[1], args[2:], xrePath=options.xrePath, testFile=options.testFile, interactive=options.interactive):
+  if not runTests(args[0], testdirs=args[1:],
+                  xrePath=options.xrePath,
+                  testFile=options.testFile,
+                  interactive=options.interactive,
+                  keepGoing=options.keepGoing,
+                  manifest=options.manifest):
     sys.exit(1)
 
 if __name__ == '__main__':
   main()
--- a/toolkit/mozapps/update/test/unit/head_update.js
+++ b/toolkit/mozapps/update/test/unit/head_update.js
@@ -181,17 +181,17 @@ xhr.prototype = {
 /**
  * Removes the updates directory and the active-update.xml file if they exist.
  * This prevents some tests from failing due to files being left behind when
  * the tests are interrupted.
  */
 function remove_dirs_and_files () {
   var fileLocator = AUS_Cc["@mozilla.org/file/directory_service;1"]
                       .getService(AUS_Ci.nsIProperties);
-  var dir = fileLocator.get("XCurProcD", AUS_Ci.nsIFile);
+  var dir = fileLocator.get("GreD", AUS_Ci.nsIFile);
 
   var file = dir.clone();
   file.append("active-update.xml");
   if (file.exists())
     file.remove(false);
 
   file = dir.clone();
   file.append("updates.xml");
--- a/toolkit/mozapps/update/test/unit/test_0110_general.js
+++ b/toolkit/mozapps/update/test/unit/test_0110_general.js
@@ -72,17 +72,17 @@ function run_test() {
   gTestDir.create(AUS_Ci.nsIFile.DIRECTORY_TYPE, 0755);
 
   // Create an empty test file to test the complete mar's ability to replace an
   // existing file.
   var testFile = gTestDir.clone();
   testFile.append("text1");
   testFile.create(AUS_Ci.nsIFile.NORMAL_FILE_TYPE, 0644);
 
-  var binDir = fileLocator.get("XCurProcD", AUS_Ci.nsIFile);
+  var binDir = fileLocator.get("GreD", AUS_Ci.nsIFile);
 
   // The updater binary file
   gUpdater = binDir.clone();
   gUpdater.append("updater.app");
   if (!gUpdater.exists()) {
     gUpdater = binDir.clone();
     gUpdater.append("updater.exe");
     if (!gUpdater.exists()) {
--- a/uriloader/exthandler/tests/Makefile.in
+++ b/uriloader/exthandler/tests/Makefile.in
@@ -62,8 +62,12 @@ LIBS +=		\
 		$(NSPR_LIBS) \
 		$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 export PERSONAL_MAILCAP=$(shell cd $(srcdir) && pwd)/mailcap
 endif
+
+# need the executable for running the xpcshell unit tests
+libs::
+	$(INSTALL) $(SIMPLE_PROGRAMS) $(DEPTH)/_tests/xpcshell/$(MODULE)/unit
--- a/uriloader/exthandler/tests/unit/test_punycodeURIs.js
+++ b/uriloader/exthandler/tests/unit/test_punycodeURIs.js
@@ -39,17 +39,17 @@
 const kTestURI = "http://\u65e5\u672c\u8a93.jp/";
 const kExpectedURI = "http://xn--wgv71a309e.jp/";
 const kOutputFile = "result.txt";
 
 function checkFile() {
   // This is where we expect the output
   var tempFile = Components.classes["@mozilla.org/file/local;1"].
     createInstance(Components.interfaces.nsILocalFile);
-  tempFile = HandlerServiceTest._dirSvc.get("CurProcD", Components.interfaces.nsIFile);
+  tempFile = do_get_cwd();
   tempFile.append(kOutputFile);
 
   if (!tempFile.exists())
     do_throw("Expected File " + tempFile.path + " does not exist");
 
   // Now read it
   var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
     createInstance(Components.interfaces.nsIFileInputStream);
@@ -97,17 +97,17 @@ function run_test() {
 
   // set up the local handler object
   var localHandler = 
     Components.classes["@mozilla.org/uriloader/local-handler-app;1"].
     createInstance(Components.interfaces.nsILocalHandlerApp);
   localHandler.name = "Test Local Handler App";
 
   // WriteArgument will just dump its arguments to a file for us.
-  var processDir = HandlerServiceTest._dirSvc.get("CurProcD", Components.interfaces.nsIFile);
+  var processDir = do_get_cwd();
   var exe = processDir.clone();
   exe.append("WriteArgument");
 
   if (!exe.exists()) {
     // Maybe we are on windows
     exe.leafName = "WriteArgument.exe";
     if (!exe.exists())
       do_throw("Could not locate the WriteArgument tests executable\n");
@@ -118,19 +118,22 @@ function run_test() {
 
   // Set an environment variable for WriteArgument to pick up
   var envSvc = Components.classes["@mozilla.org/process/environment;1"].
     getService(Components.interfaces.nsIEnvironment);
 
   // The Write Argument file needs to know where its libraries are, so
   // just force the path variable
   // For mac
-  envSvc.set("DYLD_LIBRARY_PATH", processDir.path);
-  // For Linux/Windows
-  envSvc.set("LD_LIBRARY_PATH", processDir.path);
+  var greDir = HandlerServiceTest._dirSvc.get("GreD", Components.interfaces.nsIFile);
+
+  envSvc.set("DYLD_LIBRARY_PATH", greDir.path);
+  // For Linux
+  envSvc.set("LD_LIBRARY_PATH", greDir.path);
+  //XXX: handle windows
 
   // Now tell it where we want the file.
   envSvc.set("WRITE_ARGUMENT_FILE", outFile.path);
 
   var uri = ioService.newURI(kTestURI, null, null);
 
   // Just check we've got these matching, if we haven't there's a problem
   // with ascii spec or our test case.
--- a/xpcom/tests/Makefile.in
+++ b/xpcom/tests/Makefile.in
@@ -147,16 +147,17 @@ include $(topsrcdir)/config/rules.mk
 
 LOCAL_INCLUDES	= \
                 -I$(srcdir)/../ds \
 		-I$(srcdir)/services \
 		$(NULL)
 
 libs::
 	$(INSTALL) $(srcdir)/test.properties $(DIST)/bin/res
+	$(INSTALL) $(SIMPLE_PROGRAMS) $(DEPTH)/_tests/xpcshell/$(MODULE)/unit
 
 # Copy TestHarness.h into its own module, for ease of setting up includes
 # correctly.
 export::
 	$(NSINSTALL) -D $(DIST)/include/testing
 	$(INSTALL) $(srcdir)/TestHarness.h $(DIST)/include/testing
 
 install::
--- a/xpcom/tests/unit/test_nsIProcess.js
+++ b/xpcom/tests/unit/test_nsIProcess.js
@@ -30,50 +30,53 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 // nsIProcess unit test
 
-// get the path to {objdir}/dist/bin
-var bindir = Components.classes["@mozilla.org/file/directory_service;1"]
-.getService(Components.interfaces.nsIProperties)
-.get("CurProcD", Components.interfaces.nsIFile);
-
-// the the os
 var isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
 
-var filePrefix = "";
-var fileSuffix = "";
+function get_test_program(prog)
+{
+    var progPath = do_get_cwd();
+    progPath.append(prog);
+    if (isWindows) {
+	progPath.leafName = progPath.leafName + ".exe";
+    }
+    return progPath;
+}
 
-if (isWindows) {
-  filePrefix = bindir.path + "\\";
-  fileSuffix = ".exe";
-} else {
-  filePrefix = bindir.path + "/";
+function set_environment()
+{
+  var envSvc = Components.classes["@mozilla.org/process/environment;1"].
+    getService(Components.interfaces.nsIEnvironment);
+  var dirSvc = Components.classes["@mozilla.org/file/directory_service;1"].
+    getService(Components.interfaces.nsIProperties);
+  var greDir = dirSvc.get("GreD", Components.interfaces.nsIFile);
+
+  envSvc.set("DYLD_LIBRARY_PATH", greDir.path);
+  // For Linux
+  envSvc.set("LD_LIBRARY_PATH", greDir.path);
+  //XXX: handle windows
 }
 
 
 // test if a process can be started, polled for its running status
 // and then killed
 function test_kill()
 {
-  var testapp = filePrefix + "TestBlockingProcess" +fileSuffix;
-  print(testapp);
- 
-  var file = Components.classes["@mozilla.org/file/local;1"]
-                       .createInstance(Components.interfaces.nsILocalFile);
-  file.initWithPath(testapp);
+  var file = get_test_program("TestBlockingProcess");
  
   var process = Components.classes["@mozilla.org/process/util;1"]
                           .createInstance(Components.interfaces.nsIProcess);
   process.init(file);
-  
+
   do_check_false(process.isRunning);
 
   try {
     process.kill();
     do_throw("Attempting to kill a not-running process should throw");
   }
   catch (e) { }
 
@@ -91,41 +94,33 @@ function test_kill()
   }
   catch (e) { }
 }
 
 // test if we can get an exit value from an application that is
 // guaranteed to return an exit value of 42
 function test_quick()
 {
-  var testapp = filePrefix + "TestQuickReturn" + fileSuffix;
-  
-  var file = Components.classes["@mozilla.org/file/local;1"]
-                       .createInstance(Components.interfaces.nsILocalFile);
-  file.initWithPath(testapp);
+  var file = get_test_program("TestQuickReturn");
   
   var process = Components.classes["@mozilla.org/process/util;1"]
                           .createInstance(Components.interfaces.nsIProcess);
   process.init(file);
   
   // to get an exit value it must be a blocking process
   process.run(true, [], 0);
 
   do_check_eq(process.exitValue, 42);
 }
 
 // test if an argument can be successfully passed to an application
 // that will return -1 if "mozilla" is not the first argument
 function test_arguments()
 {
-  var testapp = filePrefix + "TestArguments" + fileSuffix;
-  
-  var file = Components.classes["@mozilla.org/file/local;1"]
-                       .createInstance(Components.interfaces.nsILocalFile);
-  file.initWithPath(testapp);
+  var file = get_test_program("TestArguments");
   
   var process = Components.classes["@mozilla.org/process/util;1"]
                           .createInstance(Components.interfaces.nsIProcess);
   process.init(file);
   
   var args= ["mozilla"];
   
   process.run(true, args, args.length);
@@ -135,22 +130,18 @@ function test_arguments()
 }
 
 var gProcess;
 
 // test if we can get an exit value from an application that is
 // run non-blocking
 function test_nonblocking()
 {
-  var testapp = filePrefix + "TestQuickReturn" + fileSuffix;
-  
-  var file = Components.classes["@mozilla.org/file/local;1"]
-                       .createInstance(Components.interfaces.nsILocalFile);
-  file.initWithPath(testapp);
-  
+  var file = get_test_program("TestQuickReturn");
+
   gProcess = Components.classes["@mozilla.org/process/util;1"]
                        .createInstance(Components.interfaces.nsIProcess);
   gProcess.init(file);
 
   gProcess.run(false, [], 0);
 
   do_test_pending();
   do_timeout(100, "check_nonblocking()");
@@ -163,14 +154,15 @@ function check_nonblocking()
     return;
   }
 
   do_check_eq(gProcess.exitValue, 42);
   do_test_finished();
 }
 
 function run_test() {
+  set_environment();
   test_kill();
   test_quick();
   test_arguments();
   if (isWindows)
     test_nonblocking();
 }