Bug 351968 - Don't copy xpcshell tests and other data to $(DIST) -- a step toward being able to --enable-tests on Mozilla tinderboxen. r=bsmedberg

git-svn-id: svn://10.0.0.236/trunk@219219 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jwalden%mit.edu 2007-01-31 03:25:46 +00:00
parent a2ca505564
commit 83d07a5ce5
35 changed files with 312 additions and 197 deletions

View File

@ -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_<yourmodule>
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

View File

@ -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 <bryner@brianryner.com>
* Dietrich Ayala <dietrich@mozilla.com>
*
* 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();

View File

@ -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 <dietrich@mozilla.com>
*
* 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();

View File

@ -23,6 +23,7 @@
# Contributor(s):
# Chase Phillips <chase@mozilla.org>
# Benjamin Smedberg <benjamin@smedbergs.us>
# Jeff Walden <jwalden+code@mit.edu>
#
# 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
#############################################################################

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -35,6 +35,10 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = test_embedding
XPCSHELL_TESTS = unit
ifeq ($(OS_ARCH),OS2)
DIRS = os2Embed
endif

View File

@ -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

View File

@ -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

View File

@ -72,7 +72,7 @@ endif
ifeq ($(OS_ARCH),WINNT)
ifdef ENABLE_TESTS
ifndef MOZ_ENABLE_LIBXUL
TOOL_DIRS = tests
DIRS += tests
endif
endif
endif

View File

@ -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

View File

@ -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();

View File

@ -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)

View File

@ -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");

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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";

View File

@ -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";

View File

@ -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;

View File

@ -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";

View File

@ -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;

View File

@ -55,13 +55,6 @@ include $(DEPTH)/config/autoconf.mk
# Note: set the test module's name to test_<yourmodule>
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)

View File

@ -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/

View File

@ -21,6 +21,7 @@
#
# Contributor(s):
# Boris Zbarsky <bzbarsky@mit.edu> (Original author)
# Jeff Walden <jwalden+code@mit.edu>
#
# 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_<yourmodule>
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)

View File

@ -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"];
}

View File

@ -24,6 +24,7 @@
# Contributor(s):
# Darin Fisher <darin@meer.net>
# Dave Liebreich <davel@mozilla.com>
# Jeff Walden <jwalden+code@mit.edu>
#
# 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"

View File

@ -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