diff --git a/mozilla/browser/components/places/tests/Makefile.in b/mozilla/browser/components/places/tests/Makefile.in index 2d8488d289a..17c72bdba35 100644 --- a/mozilla/browser/components/places/tests/Makefile.in +++ b/mozilla/browser/components/places/tests/Makefile.in @@ -36,15 +36,6 @@ # # ***** END LICENSE BLOCK ***** -# -# Makefile for installing and running xpcshell-based tests. You can use -# this file as template when creating tests for a new module. Don't -# forget to change the lines marked below. See -# http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests -# for detailed instructions. -# - -# Note: DEPTH should be set to the relative path to mozilla/ DEPTH = ../../../.. topsrcdir = @top_srcdir@ srcdir = @srcdir@ @@ -52,21 +43,12 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk -# Note: set the test module's name to test_ MODULE = test_places -include $(topsrcdir)/config/rules.mk +XPCSHELL_TESTS = unit -_UNIT_FILES := $(wildcard $(srcdir)/unit/*.js) -ifndef MOZ_PLACES_BOOKMARKS -_UNIT_FILES := $(patsubst %marks.js,,$(_UNIT_FILES)) -_UNIT_FILES += $(wildcard $(srcdir)/unit/head*.js) -_UNIT_FILES += $(wildcard $(srcdir)/unit/tail*.js) +ifdef MOZ_PLACES_BOOKMARKS +XPCSHELL_TESTS += bookmarks endif -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/$(MODULE) - -# Note: Invoke any additional (non-xpcshell) test programs here. -check:: - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/$(MODULE) +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/browser/components/places/tests/bookmarks/head_bookmarks.js b/mozilla/browser/components/places/tests/bookmarks/head_bookmarks.js new file mode 100644 index 00000000000..60aa842bb50 --- /dev/null +++ b/mozilla/browser/components/places/tests/bookmarks/head_bookmarks.js @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Places. + * + * The Initial Developer of the Original Code is + * Google Inc. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Brian Ryner + * Dietrich Ayala + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * 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 ***** */ + +const NS_APP_USER_PROFILE_50_DIR = "ProfD"; +const Ci = Components.interfaces; +const Cc = Components.classes; +const Cr = Components.results; + +// If there's no location registered for the profile direcotry, register one now. +var dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); +var profileDir = null; +try { + profileDir = dirSvc.get(NS_APP_USER_PROFILE_50_DIR, Ci.nsIFile); +} catch (e) {} +if (!profileDir) { + // Register our own provider for the profile directory. + // It will simply return the current directory. + var provider = { + getFile: function(prop, persistent) { + persistent.value = true; + if (prop == NS_APP_USER_PROFILE_50_DIR) { + return dirSvc.get("CurProcD", Ci.nsIFile); + } + throw Cr.NS_ERROR_FAILURE; + }, + QueryInterface: function(iid) { + if (iid.equals(Ci.nsIDirectoryServiceProvider) || + iid.equals(Ci.nsISupports)) { + return this; + } + throw Cr.NS_ERROR_NO_INTERFACE; + } + }; + dirSvc.QueryInterface(Ci.nsIDirectoryService).registerProvider(provider); +} + +var iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); + +function uri(spec) { + return iosvc.newURI(spec, null, null); +} + +// Delete a previously created sqlite file +function clearDB() { + try { + var file = dirSvc.get('ProfD', Ci.nsIFile); + file.append("places.sqlite"); + if (file.exists()) + file.remove(false); + } catch(ex) { dump("Exception: " + ex); } +} +clearDB(); diff --git a/mozilla/browser/components/places/tests/bookmarks/tail_bookmarks.js b/mozilla/browser/components/places/tests/bookmarks/tail_bookmarks.js new file mode 100644 index 00000000000..db9548ae64c --- /dev/null +++ b/mozilla/browser/components/places/tests/bookmarks/tail_bookmarks.js @@ -0,0 +1,41 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Places. + * + * The Initial Developer of the Original Code is + * Mozilla.org + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Dietrich Ayala + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * 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 ***** */ + +// put cleanup of the bookmarks test here. + +// remove bookmarks file +clearDB(); diff --git a/mozilla/browser/components/places/tests/unit/test_bookmarks.js b/mozilla/browser/components/places/tests/bookmarks/test_bookmarks.js similarity index 100% rename from mozilla/browser/components/places/tests/unit/test_bookmarks.js rename to mozilla/browser/components/places/tests/bookmarks/test_bookmarks.js diff --git a/mozilla/browser/components/places/tests/unit/test_livemarks.js b/mozilla/browser/components/places/tests/bookmarks/test_livemarks.js similarity index 100% rename from mozilla/browser/components/places/tests/unit/test_livemarks.js rename to mozilla/browser/components/places/tests/bookmarks/test_livemarks.js diff --git a/mozilla/config/rules.mk b/mozilla/config/rules.mk index 1704fb8332a..9ad57fec054 100644 --- a/mozilla/config/rules.mk +++ b/mozilla/config/rules.mk @@ -23,6 +23,7 @@ # Contributor(s): # Chase Phillips # Benjamin Smedberg +# Jeff Walden # # Alternatively, the contents of this file may be used under the terms of # either of the GNU General Public License Version 2 or later (the "GPL"), @@ -397,7 +398,7 @@ endif endif # -# This will strip out symbols that the component shouldnt be +# This will strip out symbols that the component should not be # exporting from the .dynsym section. # ifdef IS_COMPONENT @@ -1529,7 +1530,7 @@ endif # XPIDLSRCS # General rules for exporting idl files. # # WORK-AROUND ONLY, for mozilla/tools/module-deps/bootstrap.pl build. -# Bug to fix idl dependecy problems w/o this extra build pass is +# Bug to fix idl dependency problems w/o this extra build pass is # http://bugzilla.mozilla.org/show_bug.cgi?id=145777 # $(IDL_DIR):: @@ -1798,6 +1799,50 @@ REGCHROME_INSTALL = $(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-ch $(if $(CROSS_COMPILE),-o $(OS_ARCH)) $(DESTDIR)$(mozappdir)/chrome/installed-chrome.txt \ $(_JAR_REGCHROME_DISABLE_JAR) + +################################################################################ +# Testing frameworks support +################################################################################ + +ifdef ENABLE_TESTS + +ifdef XPCSHELL_TESTS +ifndef MODULE +$(error Must define MODULE when defining XPCSHELL_TESTS.) +endif + +# Test file installation +libs:: + @$(EXIT_ON_ERROR) \ + for testdir in $(XPCSHELL_TESTS); do \ + $(INSTALL) \ + $(srcdir)/$$testdir/*.js \ + $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \ + done + +ifdef CYGWIN_WRAPPER +NATIVE_TOPSRCDIR := `cygpath -wa $(topsrcdir)` +else +NATIVE_TOPSRCDIR := $(topsrcdir) +endif # CYGWIN_WRAPPER + +# Test execution +check:: + @$(EXIT_ON_ERROR) \ + for testdir in $(XPCSHELL_TESTS); do \ + $(RUN_TEST_PROGRAM) \ + $(topsrcdir)/tools/test-harness/xpcshell-simple/test_all.sh \ + $(DIST)/bin/xpcshell \ + $(topsrcdir) \ + $(NATIVE_TOPSRCDIR) \ + $(DEPTH)/_tests/xpcshell-simple/$(MODULE)/$$testdir; \ + done + +endif # XPCSHELL_TESTS + +endif # ENABLE_TESTS + + ############################################################################# # Dependency system ############################################################################# diff --git a/mozilla/content/test/Makefile.in b/mozilla/content/test/Makefile.in index ea0593c4c0c..35837070530 100644 --- a/mozilla/content/test/Makefile.in +++ b/mozilla/content/test/Makefile.in @@ -45,17 +45,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = test_content +XPCSHELL_TESTS = unit + include $(topsrcdir)/config/rules.mk - -_UNIT_FILES := \ - $(wildcard $(srcdir)/unit/*.js) \ - $(wildcard $(srcdir)/unit/*.xml) \ - $(wildcard $(srcdir)/unit/*.xul) \ - $(NULL) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/content_unit_tests - -check:: - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh \ - $(DIST)/bin/content_unit_tests diff --git a/mozilla/content/test/unit/head_content.js b/mozilla/content/test/unit/head_content.js index 866a2264ea3..5396d869d27 100644 --- a/mozilla/content/test/unit/head_content.js +++ b/mozilla/content/test/unit/head_content.js @@ -61,13 +61,19 @@ function DOMParser() { return C["@mozilla.org/xmlextras/domparser;1"].createInstance(nsIDOMParser); } +var __testsDirectory = null; + function ParseFile(file) { if (typeof(file) == "string") { - var dirServ = C["@mozilla.org/file/directory_service;1"] - .getService(nsIProperties); - var dummy = {}; - var fileObj = dirServ.get("CurProcD", nsILocalFile); - fileObj.append("content_unit_tests"); + if (!__testsDirectory) { + __testsDirectory = C["@mozilla.org/file/local;1"] + .createInstance(I.nsILocalFile); + __testsDirectory.initWithPath(do_get_topsrcdir()); + __testsDirectory.append("content"); + __testsDirectory.append("test"); + __testsDirectory.append("unit"); + } + var fileObj = __testsDirectory.clone(); fileObj.append(file); file = fileObj; } diff --git a/mozilla/embedding/Makefile.in b/mozilla/embedding/Makefile.in index 4e9fad9a889..6ad23c71ebc 100644 --- a/mozilla/embedding/Makefile.in +++ b/mozilla/embedding/Makefile.in @@ -52,16 +52,8 @@ ifndef MOZ_XUL_APP DIRS += lite endif -include $(topsrcdir)/config/rules.mk - ifdef ENABLE_TESTS - -_UNIT_FILES := $(wildcard $(srcdir)/tests/unit/*.js) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/embedding_unit_tests - -check:: - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/embedding_unit_tests - +DIRS += tests endif + +include $(topsrcdir)/config/rules.mk diff --git a/mozilla/embedding/tests/Makefile.in b/mozilla/embedding/tests/Makefile.in index ef298d8ed65..3f1bf1709ab 100644 --- a/mozilla/embedding/tests/Makefile.in +++ b/mozilla/embedding/tests/Makefile.in @@ -35,6 +35,10 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk +MODULE = test_embedding + +XPCSHELL_TESTS = unit + ifeq ($(OS_ARCH),OS2) DIRS = os2Embed endif diff --git a/mozilla/extensions/metrics/Makefile.in b/mozilla/extensions/metrics/Makefile.in index 2a7124a351f..5859ff1a867 100644 --- a/mozilla/extensions/metrics/Makefile.in +++ b/mozilla/extensions/metrics/Makefile.in @@ -51,7 +51,7 @@ XPI_PKGNAME = metrics-$(MOZ_APP_VERSION) DIRS = public src build ifdef ENABLE_TESTS -TOOL_DIRS += test +DIRS += test endif PREF_JS_EXPORTS = $(srcdir)/metrics.js diff --git a/mozilla/extensions/metrics/test/Makefile.in b/mozilla/extensions/metrics/test/Makefile.in index ff52946a5e4..f7d140d2825 100644 --- a/mozilla/extensions/metrics/test/Makefile.in +++ b/mozilla/extensions/metrics/test/Makefile.in @@ -72,9 +72,9 @@ LIBS = \ $(NSPR_LIBS) \ $(NULL) -include $(topsrcdir)/config/rules.mk +XPCSHELL_TESTS = unit -_UNIT_FILES := $(wildcard $(srcdir)/unit/*.js) +include $(topsrcdir)/config/rules.mk # Give the unit tests absolute paths to the data and temp directories. # For cygwin, we need to convert the paths to native Windows paths. @@ -86,14 +86,9 @@ TESTDATA_DIR := `cd $(srcdir)/data; pwd` TEST_TMPDIR := `pwd` endif -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/metrics_unit_tests - check:: @echo Running tests... @for f in $(SIMPLE_PROGRAMS); do \ echo $$f; $(RUN_TEST_PROGRAM) $(DIST)/bin/$$f \ $(TESTDATA_DIR) $(TEST_TMPDIR); \ done - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh \ - $(DIST)/bin/metrics_unit_tests diff --git a/mozilla/intl/uconv/Makefile.in b/mozilla/intl/uconv/Makefile.in index 90eaec1b804..9498ef7db2a 100644 --- a/mozilla/intl/uconv/Makefile.in +++ b/mozilla/intl/uconv/Makefile.in @@ -72,7 +72,7 @@ endif ifeq ($(OS_ARCH),WINNT) ifdef ENABLE_TESTS ifndef MOZ_ENABLE_LIBXUL -TOOL_DIRS = tests +DIRS += tests endif endif endif diff --git a/mozilla/intl/uconv/tests/Makefile.in b/mozilla/intl/uconv/tests/Makefile.in index 4838857888a..6691f32a07a 100644 --- a/mozilla/intl/uconv/tests/Makefile.in +++ b/mozilla/intl/uconv/tests/Makefile.in @@ -42,6 +42,8 @@ VPATH = @srcdir@ include $(DEPTH)/config/autoconf.mk +MODULE = test_intl_uconv + MOZILLA_INTERNAL_API = 1 REQUIRES = \ @@ -63,6 +65,8 @@ endif SIMPLE_PROGRAMS = $(CPPSRCS:.cpp=$(BIN_SUFFIX)) +XPCSHELL_TESTS = unit + include $(topsrcdir)/config/rules.mk INCLUDES += \ @@ -83,18 +87,3 @@ ifneq ($(OS_RELEASE),1.2) OS_LIBS += /usr/lib/libdl.so endif endif - -# Unit tests -_UNIT_FILES := $(wildcard $(srcdir)/unit/*.js) -_DATA_FILES := $(wildcard $(srcdir)/unit/data/*.txt) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/intl_unit_tests - -libs:: $(_DATA_FILES) - $(INSTALL) $^ $(DIST)/bin/intl_unit_tests/data - -check:: - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/intl_unit_tests - - diff --git a/mozilla/intl/uconv/tests/unit/test_charset_conversion.js b/mozilla/intl/uconv/tests/unit/test_charset_conversion.js index 64cb1494f31..44a182e7dfc 100644 --- a/mozilla/intl/uconv/tests/unit/test_charset_conversion.js +++ b/mozilla/intl/uconv/tests/unit/test_charset_conversion.js @@ -31,10 +31,13 @@ function run_test() "nsIConverterInputStream", "init"); - var dirServ = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties); - dataDir = dirServ.get("CurProcD", Ci.nsILocalFile); - dataDir.append("intl_unit_tests"); + dataDir = Cc["@mozilla.org/file/local;1"] + .getService(Ci.nsILocalFile); + dataDir.initWithPath(do_get_topsrcdir()); + dataDir.append("intl"); + dataDir.append("uconv"); + dataDir.append("tests"); + dataDir.append("unit"); dataDir.append("data"); test_utf8_1(); diff --git a/mozilla/modules/libjar/test/Makefile.in b/mozilla/modules/libjar/test/Makefile.in index 66681c97cea..346e090b41a 100644 --- a/mozilla/modules/libjar/test/Makefile.in +++ b/mozilla/modules/libjar/test/Makefile.in @@ -45,13 +45,6 @@ include $(DEPTH)/config/autoconf.mk MODULE = test_libjar +XPCSHELL_TESTS = unit + include $(topsrcdir)/config/rules.mk - -_UNIT_FILES := $(wildcard $(srcdir)/unit/*.js) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/$(MODULE) - -check:: - $(ZIP) -q test_bug333423.zip Makefile - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/$(MODULE) diff --git a/mozilla/modules/libjar/test/unit/data/test_bug333423.zip b/mozilla/modules/libjar/test/unit/data/test_bug333423.zip new file mode 100644 index 00000000000..42662a40857 Binary files /dev/null and b/mozilla/modules/libjar/test/unit/data/test_bug333423.zip differ diff --git a/mozilla/modules/libjar/test/unit/test_bug333423.js b/mozilla/modules/libjar/test/unit/test_bug333423.js index f8efb2a1ce5..ad24649abfd 100644 --- a/mozilla/modules/libjar/test/unit/test_bug333423.js +++ b/mozilla/modules/libjar/test/unit/test_bug333423.js @@ -44,8 +44,14 @@ function run_test() { const Ci = Components.interfaces; // the build script have created the zip we can test on in the current dir. - var file = Cc["@mozilla.org/file/directory_service;1"]. - getService(Ci.nsIProperties).get("CurWorkD", Ci.nsIFile); + var file = Cc["@mozilla.org/file/local;1"] + .createInstance(Ci.nsILocalFile); + file.initWithPath(do_get_topsrcdir()); + file.append("modules"); + file.append("libjar"); + file.append("test"); + file.append("unit"); + file.append("data"); file.append("test_bug333423.zip") dump("Using " + file.path + " for testing\n"); diff --git a/mozilla/netwerk/test/Makefile.in b/mozilla/netwerk/test/Makefile.in index 3eb26e7a297..64cd1705057 100644 --- a/mozilla/netwerk/test/Makefile.in +++ b/mozilla/netwerk/test/Makefile.in @@ -98,16 +98,12 @@ LIBS = $(EXTRA_DSO_LIBS) \ DEFINES += $(TK_CFLAGS) +XPCSHELL_TESTS = unit + include $(topsrcdir)/config/rules.mk -_UNIT_FILES := $(wildcard $(srcdir)/unit/*.js) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/necko_unit_tests - check:: $(RUN_TEST_PROGRAM) $(DIST)/bin/TestCookie - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/necko_unit_tests _RES_FILES = urlparse.dat \ urlparse_unx.dat \ diff --git a/mozilla/netwerk/test/httpserver/Makefile.in b/mozilla/netwerk/test/httpserver/Makefile.in index 129786431ca..d401841e7c6 100644 --- a/mozilla/netwerk/test/httpserver/Makefile.in +++ b/mozilla/netwerk/test/httpserver/Makefile.in @@ -49,33 +49,6 @@ XPIDLSRCS = \ nsIHttpServer.idl \ $(NULL) +XPCSHELL_TESTS = test + include $(topsrcdir)/config/rules.mk - -_UNIT_FILES := $(wildcard $(srcdir)/test/*.js) - -_SERVER_SCRIPT_FILES = \ - httpd.js \ - $(NULL) - -# copy the server to the xpcshell test harness directory -libs:: $(_SERVER_SCRIPT_FILES) - $(INSTALL) $^ $(DIST)/bin/test-harness/xpcshell-simple - -# -# Server tests don't go in with necko's tests because: -# -# - we then have to think about file name conflicts in two different locations -# - head_*.js files in separate locations are both run, even when this is not -# desired (e.g., we must either always import httpd.js [slowing down test -# processing even for tests which don't need it] or we must manually import -# it in every test that uses it [which would be extremely annoying for the -# server tests which all want it]) -# - httpd.js doesn't clutter the global scope too much, but it does become a -# concern (consider Cc/Ci/Cr in particular, which as constants cannot be -# safely redefined) -# -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/httpserver_tests - -check:: - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/httpserver_tests diff --git a/mozilla/netwerk/test/httpserver/test/head_utils.js b/mozilla/netwerk/test/httpserver/test/head_utils.js index 74dc332409b..4e92ef04367 100644 --- a/mozilla/netwerk/test/httpserver/test/head_utils.js +++ b/mozilla/netwerk/test/httpserver/test/head_utils.js @@ -36,7 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ -do_import_script("test-harness/xpcshell-simple/httpd.js"); +do_import_script("netwerk/test/httpserver/httpd.js"); /** * Constructs a new nsHttpServer instance. This function is intended to diff --git a/mozilla/netwerk/test/httpserver/test/test_registerdirectory.js b/mozilla/netwerk/test/httpserver/test/test_registerdirectory.js index e7de5f7466c..d2af43a4252 100644 --- a/mozilla/netwerk/test/httpserver/test/test_registerdirectory.js +++ b/mozilla/netwerk/test/httpserver/test/test_registerdirectory.js @@ -173,15 +173,11 @@ var listener = }, onStopRequest: function(request, cx, status) { - var dirServ; switch (currPathIndex) { case 0: // now set a base path - dirServ = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties); - serverBasePath = dirServ.get("CurProcD", Ci.nsILocalFile); - serverBasePath.append("httpserver_tests"); + serverBasePath = testsDirectory.clone(); srv.registerDirectory("/", serverBasePath); break; @@ -204,10 +200,7 @@ var listener = case 5: // set the base path again - dirServ = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties); - serverBasePath = dirServ.get("CurProcD", Ci.nsILocalFile); - serverBasePath.append("httpserver_tests"); + serverBasePath = testsDirectory.clone(); srv.registerDirectory("/", serverBasePath); break; @@ -230,10 +223,7 @@ var listener = case 9: // register /foo/ as a base path - dirServ = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties); - serverBasePath = dirServ.get("CurProcD", Ci.nsILocalFile); - serverBasePath.append("httpserver_tests"); + serverBasePath = testsDirectory.clone(); srv.registerDirectory("/foo/", serverBasePath); break; @@ -292,9 +282,18 @@ function performNextTest() var srv; var serverBasePath; +var testsDirectory; function run_test() { + testsDirectory = Cc["@mozilla.org/file/local;1"] + .createInstance(Ci.nsILocalFile); + testsDirectory.initWithPath(do_get_topsrcdir()); + testsDirectory.append("netwerk"); + testsDirectory.append("test"); + testsDirectory.append("httpserver"); + testsDirectory.append("test"); + srv = createServer(); srv.start(4444); diff --git a/mozilla/netwerk/test/httpserver/test/test_setindexhandler.js b/mozilla/netwerk/test/httpserver/test/test_setindexhandler.js index 33185aa7268..00a5e282d76 100644 --- a/mozilla/netwerk/test/httpserver/test/test_setindexhandler.js +++ b/mozilla/netwerk/test/httpserver/test/test_setindexhandler.js @@ -104,10 +104,14 @@ var srv, serverBasePath; function run_test() { srv = createServer(); - var dirServ = Cc["@mozilla.org/file/directory_service;1"] - .getService(Ci.nsIProperties); - serverBasePath = dirServ.get("CurProcD", Ci.nsILocalFile); - serverBasePath.append("httpserver_tests"); + serverBasePath = Cc["@mozilla.org/file/local;1"] + .createInstance(Ci.nsILocalFile); + serverBasePath.initWithPath(do_get_topsrcdir()); + serverBasePath.append("netwerk"); + serverBasePath.append("test"); + serverBasePath.append("httpserver"); + serverBasePath.append("test"); + serverBasePath.QueryInterface(Ci.nsIFile); srv.registerDirectory("/", serverBasePath); srv.setIndexHandler(myIndexHandler); srv.start(4444); diff --git a/mozilla/netwerk/test/unit/test_authentication.js b/mozilla/netwerk/test/unit/test_authentication.js index 85c889881f3..d893d611307 100644 --- a/mozilla/netwerk/test/unit/test_authentication.js +++ b/mozilla/netwerk/test/unit/test_authentication.js @@ -1,6 +1,6 @@ // This file tests authentication prompt callbacks -do_import_script("test-harness/xpcshell-simple/httpd.js"); +do_import_script("netwerk/test/httpserver/httpd.js"); const FLAG_RETURN_FALSE = 1 << 0; const FLAG_WRONG_PASSWORD = 1 << 1; diff --git a/mozilla/netwerk/test/unit/test_bug331825.js b/mozilla/netwerk/test/unit/test_bug331825.js index 39c537e2937..08b68b1d70e 100644 --- a/mozilla/netwerk/test/unit/test_bug331825.js +++ b/mozilla/netwerk/test/unit/test_bug331825.js @@ -1,4 +1,4 @@ -do_import_script("test-harness/xpcshell-simple/httpd.js"); +do_import_script("netwerk/test/httpserver/httpd.js"); var server; var BUGID = "331825"; diff --git a/mozilla/netwerk/test/unit/test_content_sniffer.js b/mozilla/netwerk/test/unit/test_content_sniffer.js index 664ff2b3f05..013de2bd9d2 100644 --- a/mozilla/netwerk/test/unit/test_content_sniffer.js +++ b/mozilla/netwerk/test/unit/test_content_sniffer.js @@ -1,6 +1,6 @@ // This file tests nsIContentSniffer, introduced in bug 324985 -do_import_script("test-harness/xpcshell-simple/httpd.js"); +do_import_script("netwerk/test/httpserver/httpd.js"); const unknownType = "application/x-unknown-content-type"; const sniffedType = "application/x-sniffed"; diff --git a/mozilla/netwerk/test/unit/test_cookie_header.js b/mozilla/netwerk/test/unit/test_cookie_header.js index 5451ce9d4b1..a5a880a8948 100644 --- a/mozilla/netwerk/test/unit/test_cookie_header.js +++ b/mozilla/netwerk/test/unit/test_cookie_header.js @@ -1,6 +1,6 @@ // This file tests bug 250375 -do_import_script("test-harness/xpcshell-simple/httpd.js"); +do_import_script("netwerk/test/httpserver/httpd.js"); function check_request_header(chan, name, value) { var chanValue; diff --git a/mozilla/netwerk/test/unit/test_event_sink.js b/mozilla/netwerk/test/unit/test_event_sink.js index 371c6ee8e29..e896ff552a9 100644 --- a/mozilla/netwerk/test/unit/test_event_sink.js +++ b/mozilla/netwerk/test/unit/test_event_sink.js @@ -1,6 +1,6 @@ // This file tests channel event sinks (bug 315598 et al) -do_import_script("test-harness/xpcshell-simple/httpd.js"); +do_import_script("netwerk/test/httpserver/httpd.js"); const sinkCID = Components.ID("{14aa4b81-e266-45cb-88f8-89595dece114}"); const sinkContract = "@mozilla.org/network/unittest/channeleventsink;1"; diff --git a/mozilla/netwerk/test/unit/test_httpcancel.js b/mozilla/netwerk/test/unit/test_httpcancel.js index 52a404af21e..ecf73ed79ac 100644 --- a/mozilla/netwerk/test/unit/test_httpcancel.js +++ b/mozilla/netwerk/test/unit/test_httpcancel.js @@ -1,7 +1,7 @@ // This file ensures that canceling a channel early does not // send the request to the server (bug 350790) -do_import_script("test-harness/xpcshell-simple/httpd.js"); +do_import_script("netwerk/test/httpserver/httpd.js"); const NS_BINDING_ABORTED = 0x804b0002; diff --git a/mozilla/parser/xml/test/Makefile.in b/mozilla/parser/xml/test/Makefile.in index 6c8113f1773..a9e163b8d87 100644 --- a/mozilla/parser/xml/test/Makefile.in +++ b/mozilla/parser/xml/test/Makefile.in @@ -55,13 +55,6 @@ include $(DEPTH)/config/autoconf.mk # Note: set the test module's name to test_ MODULE = test_xmlreader +XPCSHELL_TESTS = unit + include $(topsrcdir)/config/rules.mk - -_UNIT_FILES := $(wildcard $(srcdir)/unit/*.js) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/$(MODULE) - -# Note: Invoke any additional (non-xpcshell) test programs here. -check:: - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/$(MODULE) diff --git a/mozilla/tools/test-harness/xpcshell-simple/Makefile.in b/mozilla/tools/test-harness/xpcshell-simple/Makefile.in index b0abddbea22..ae152ed0b5b 100644 --- a/mozilla/tools/test-harness/xpcshell-simple/Makefile.in +++ b/mozilla/tools/test-harness/xpcshell-simple/Makefile.in @@ -52,14 +52,3 @@ DIRS += example endif include $(topsrcdir)/config/rules.mk - -_TEST_FILES = test_all.sh -_UNIT_FILES = head.js \ - tail.js \ - $(NULL) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/test-harness/xpcshell-simple - -libs:: $(_TEST_FILES) - $(INSTALL) $^ $(DIST)/bin/ diff --git a/mozilla/tools/test-harness/xpcshell-simple/example/Makefile.in b/mozilla/tools/test-harness/xpcshell-simple/example/Makefile.in index 3edc762447c..fa5ed97d3dc 100644 --- a/mozilla/tools/test-harness/xpcshell-simple/example/Makefile.in +++ b/mozilla/tools/test-harness/xpcshell-simple/example/Makefile.in @@ -21,6 +21,7 @@ # # Contributor(s): # Boris Zbarsky (Original author) +# Jeff Walden # # Alternatively, the contents of this file may be used under the terms of # either of the GNU General Public License Version 2 or later (the "GPL"), @@ -55,13 +56,13 @@ include $(DEPTH)/config/autoconf.mk # Note: set the test module's name to test_ MODULE = test_harness_xpcshell_simple +# This is a list of directories containing tests to run, separated by spaces. +# Most likely, tho, you won't use more than one directory here. +XPCSHELL_TESTS = \ + unit \ + $(NULL) + include $(topsrcdir)/config/rules.mk -_UNIT_FILES := $(wildcard $(srcdir)/unit/*.js) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/$(MODULE) - # Note: Invoke any additional (non-xpcshell) test programs here. check:: - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/$(MODULE) diff --git a/mozilla/tools/test-harness/xpcshell-simple/head.js b/mozilla/tools/test-harness/xpcshell-simple/head.js index dfc349a91eb..faeb80f25eb 100644 --- a/mozilla/tools/test-harness/xpcshell-simple/head.js +++ b/mozilla/tools/test-harness/xpcshell-simple/head.js @@ -132,11 +132,15 @@ function do_test_finished() { _do_quit(); } -function do_import_script(distRelativePath) { - var scriptPath = environment["DIST"]; +function do_import_script(topsrcdirRelativePath) { + var scriptPath = environment["TOPSRCDIR"]; if (scriptPath.charAt(scriptPath.length - 1) != "/") scriptPath += "/"; - scriptPath += distRelativePath; + scriptPath += topsrcdirRelativePath; load(scriptPath); } + +function do_get_topsrcdir() { + return environment["NATIVE_TOPSRCDIR"]; +} diff --git a/mozilla/tools/test-harness/xpcshell-simple/test_all.sh b/mozilla/tools/test-harness/xpcshell-simple/test_all.sh index d348755ad4d..91caff80284 100755 --- a/mozilla/tools/test-harness/xpcshell-simple/test_all.sh +++ b/mozilla/tools/test-harness/xpcshell-simple/test_all.sh @@ -24,6 +24,7 @@ # Contributor(s): # Darin Fisher # Dave Liebreich +# Jeff Walden # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -45,24 +46,45 @@ ulimit -c 20480 2> /dev/null # Make assertions fatal export XPCOM_DEBUG_BREAK=abort -# MOZILLA_FIVE_HOME is exported by run-mozilla.sh, and is usually $(DIST)/bin -# we need to know that dir path in order to find xpcshell -bin=${MOZILLA_FIVE_HOME:-`dirname $0`} - exit_status=0 -# The sample Makefile for the xpcshell-simple harness adds the directory -# where the *.js files reside as an arg. If no arg is specified, assume -# the current directory is where the *.js files live. -testdir="$1" + +########################## +# COMMAND-LINE ARGUMENTS # +########################## + +# This provides the path to xpcshell. +xpcshell="$1" + +# The directory containing Mozilla source code is specified as the first +# argument to this script, in a format usable by load() in xpcshell. This +# enables do_import_script to work for any JS file in the source tree. +topsrcdir="$2" + +# Tests which depend on files in the source directory will need a native path +# to actually access those files, or otherwise they must rely on hacks such as +# getting the current working/process directory and committing other atrocities. +# This argument is a native path to the top-level source directory, useful for +# tests which require access to files so that they can access them in a vaguely +# clean manner. +native_topsrcdir="$3" + +# The sample Makefile for the xpcshell-simple harness adds the directory where +# the test_*.js files reside as an arg. If no arg is specified, assume the +# current directory is where the *.js files live. +testdir="$4" if [ "x$testdir" = "x" ]; then testdir=. fi -headfiles="-f $bin/test-harness/xpcshell-simple/head.js" + +############################### +# SETUP FOR RUNNING THE TESTS # +############################### # files matching the pattern head_*.js are treated like test setup files # - they are run after head.js but before the test file +headfiles="-f $topsrcdir/tools/test-harness/xpcshell-simple/head.js" for h in $testdir/head_*.js do if [ -f $h ]; then @@ -70,9 +92,9 @@ do fi done -tailfiles="-f $bin/test-harness/xpcshell-simple/tail.js" # files matching the pattern tail_*.js are treated like teardown files # - they are run after tail.js +tailfiles="-f $topsrcdir/tools/test-harness/xpcshell-simple/tail.js" for t in $testdir/tail_*.js do if [ -f $t ]; then @@ -80,10 +102,15 @@ do fi done + +################# +# RUN EACH TEST # +################# + for t in $testdir/test_*.js do echo -n "$t: " - DIST="$bin" $bin/xpcshell $headfiles -f $t $tailfiles 2> $t.log 1>&2 + NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" $xpcshell $headfiles -f $t $tailfiles 2> $t.log 1>&2 if [ `grep -c '\*\*\* PASS' $t.log` = 0 ] then echo "FAIL" diff --git a/mozilla/xpcom/tests/Makefile.in b/mozilla/xpcom/tests/Makefile.in index 4b6281968b9..7eb9fa35f24 100644 --- a/mozilla/xpcom/tests/Makefile.in +++ b/mozilla/xpcom/tests/Makefile.in @@ -113,6 +113,8 @@ endif ENABLE_CXX_EXCEPTIONS = 1 +XPCSHELL_TESTS = unit + include $(topsrcdir)/config/rules.mk LOCAL_INCLUDES = \ @@ -126,12 +128,6 @@ libs:: install:: $(SYSINSTALL) $(IFLAGS1) $(srcdir)/test.properties $(DESTDIR)$(mozappdir)/res -_UNIT_FILES = $(wildcard $(srcdir)/unit/*.js) - -libs:: $(_UNIT_FILES) - $(INSTALL) $^ $(DIST)/bin/xpcom_tests - check:: @echo "Running TestVersionComparator tests" @$(PERL) -w $(srcdir)/TestVersionComparatorRunner.pl "$(RUN_TEST_PROGRAM) $(FINAL_TARGET)/TestVersionComparator$(BIN_SUFFIX)" - $(RUN_TEST_PROGRAM) $(DIST)/bin/test_all.sh $(DIST)/bin/xpcom_tests