bug 482084 - rewrite xpcshell test harness. r=bsmedberg

This commit is contained in:
Ted Mielczarek 2009-03-11 11:56:58 -04:00
parent d0e46c0bc4
commit 9aada2da48
6 changed files with 223 additions and 445 deletions

View File

@ -131,73 +131,47 @@ endif
testxpcobjdir = $(DEPTH)/_tests/xpcshell
# Test file installation
libs::
@$(EXIT_ON_ERROR) \
for testdir in $(XPCSHELL_TESTS); do \
$(INSTALL) \
$(srcdir)/$$testdir/*.js \
$(testxpcobjdir)/$(MODULE)/$$testdir; \
done
# Path formats on Windows are hard. We require a topsrcdir formatted so that
# it may be passed to nsILocalFile.initWithPath (in other words, an absolute
# path of the form X:\path\to\topsrcdir), which we store in NATIVE_TOPSRCDIR.
# We require a forward-slashed path to topsrcdir so that it may be combined
# with a relative forward-slashed path for loading scripts, both dynamically
# and statically for head/test/tail JS files. Of course, on non-Windows none
# of this matters, and things will work correctly because everything's
# forward-slashed, everywhere, always.
ifdef CYGWIN_WRAPPER
NATIVE_TOPSRCDIR := `cygpath -wa $(topsrcdir)`
FWDSLASH_TOPSRCDIR := `cygpath -ma $(topsrcdir)`
else
FWDSLASH_TOPSRCDIR := $(topsrcdir)
ifeq ($(HOST_OS_ARCH),WINNT)
NATIVE_TOPSRCDIR := $(subst /,\\,$(WIN_TOP_SRC))
else
ifeq ($(HOST_OS_ARCH),os2-emx)
NATIVE_TOPSRCDIR := $(subst /,\\,$(topsrcdir))
else
NATIVE_TOPSRCDIR := $(topsrcdir)
endif
endif
endif # CYGWIN_WRAPPER
define _INSTALL_TESTS
$(INSTALL) $(wildcard $(srcdir)/$(dir)/*.js) $(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))
testxpcsrcdir = $(topsrcdir)/testing/xpcshell
# Test execution
# Execute all tests in the $(XPCSHELL_TESTS) directories.
check::
@$(EXIT_ON_ERROR) \
for testdir in $(XPCSHELL_TESTS); do \
$(RUN_TEST_PROGRAM) \
$(testxpcsrcdir)/test_all.sh \
$(DIST)/bin/xpcshell \
$(FWDSLASH_TOPSRCDIR) \
$(NATIVE_TOPSRCDIR) \
$(testxpcobjdir)/$(MODULE)/$$testdir; \
done
$(PYTHON) \
$(testxpcsrcdir)/runxpcshelltests.py \
$(DIST)/bin/xpcshell \
$(topsrcdir) \
$(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
# Test execution
# 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::
@$(EXIT_ON_ERROR) \
$(RUN_TEST_PROGRAM) \
$(testxpcsrcdir)/test_one.sh \
$(DIST)/bin/xpcshell \
$(FWDSLASH_TOPSRCDIR) \
$(NATIVE_TOPSRCDIR) \
$(testxpcobjdir)/$(MODULE)/$$testdir \
$(SOLO_FILE) 1;
$(PYTHON) \
$(testxpcsrcdir)/runxpcshelltests.py \
--test=$(SOLO_FILE) \
--interactive \
$(DIST)/bin/xpcshell \
$(topsrcdir) \
$(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
# Test execution
# Execute a single test, specified in $(SOLO_FILE)
check-one::
@$(EXIT_ON_ERROR) \
$(RUN_TEST_PROGRAM) \
$(testxpcsrcdir)/test_one.sh \
$(DIST)/bin/xpcshell \
$(FWDSLASH_TOPSRCDIR) \
$(NATIVE_TOPSRCDIR) \
$(testxpcobjdir)/$(MODULE)/$$testdir \
$(SOLO_FILE) 0;
$(PYTHON) \
$(testxpcsrcdir)/runxpcshelltests.py \
--test=$(SOLO_FILE) \
$(DIST)/bin/xpcshell \
$(topsrcdir) \
$(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
endif # XPCSHELL_TESTS

View File

@ -131,73 +131,47 @@ endif
testxpcobjdir = $(DEPTH)/_tests/xpcshell
# Test file installation
libs::
@$(EXIT_ON_ERROR) \
for testdir in $(XPCSHELL_TESTS); do \
$(INSTALL) \
$(srcdir)/$$testdir/*.js \
$(testxpcobjdir)/$(MODULE)/$$testdir; \
done
# Path formats on Windows are hard. We require a topsrcdir formatted so that
# it may be passed to nsILocalFile.initWithPath (in other words, an absolute
# path of the form X:\path\to\topsrcdir), which we store in NATIVE_TOPSRCDIR.
# We require a forward-slashed path to topsrcdir so that it may be combined
# with a relative forward-slashed path for loading scripts, both dynamically
# and statically for head/test/tail JS files. Of course, on non-Windows none
# of this matters, and things will work correctly because everything's
# forward-slashed, everywhere, always.
ifdef CYGWIN_WRAPPER
NATIVE_TOPSRCDIR := `cygpath -wa $(topsrcdir)`
FWDSLASH_TOPSRCDIR := `cygpath -ma $(topsrcdir)`
else
FWDSLASH_TOPSRCDIR := $(topsrcdir)
ifeq ($(HOST_OS_ARCH),WINNT)
NATIVE_TOPSRCDIR := $(subst /,\\,$(WIN_TOP_SRC))
else
ifeq ($(HOST_OS_ARCH),os2-emx)
NATIVE_TOPSRCDIR := $(subst /,\\,$(topsrcdir))
else
NATIVE_TOPSRCDIR := $(topsrcdir)
endif
endif
endif # CYGWIN_WRAPPER
define _INSTALL_TESTS
$(INSTALL) $(wildcard $(srcdir)/$(dir)/*.js) $(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))
testxpcsrcdir = $(topsrcdir)/testing/xpcshell
# Test execution
# Execute all tests in the $(XPCSHELL_TESTS) directories.
check::
@$(EXIT_ON_ERROR) \
for testdir in $(XPCSHELL_TESTS); do \
$(RUN_TEST_PROGRAM) \
$(testxpcsrcdir)/test_all.sh \
$(DIST)/bin/xpcshell \
$(FWDSLASH_TOPSRCDIR) \
$(NATIVE_TOPSRCDIR) \
$(testxpcobjdir)/$(MODULE)/$$testdir; \
done
$(PYTHON) \
$(testxpcsrcdir)/runxpcshelltests.py \
$(DIST)/bin/xpcshell \
$(topsrcdir) \
$(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
# Test execution
# 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::
@$(EXIT_ON_ERROR) \
$(RUN_TEST_PROGRAM) \
$(testxpcsrcdir)/test_one.sh \
$(DIST)/bin/xpcshell \
$(FWDSLASH_TOPSRCDIR) \
$(NATIVE_TOPSRCDIR) \
$(testxpcobjdir)/$(MODULE)/$$testdir \
$(SOLO_FILE) 1;
$(PYTHON) \
$(testxpcsrcdir)/runxpcshelltests.py \
--test=$(SOLO_FILE) \
--interactive \
$(DIST)/bin/xpcshell \
$(topsrcdir) \
$(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
# Test execution
# Execute a single test, specified in $(SOLO_FILE)
check-one::
@$(EXIT_ON_ERROR) \
$(RUN_TEST_PROGRAM) \
$(testxpcsrcdir)/test_one.sh \
$(DIST)/bin/xpcshell \
$(FWDSLASH_TOPSRCDIR) \
$(NATIVE_TOPSRCDIR) \
$(testxpcobjdir)/$(MODULE)/$$testdir \
$(SOLO_FILE) 0;
$(PYTHON) \
$(testxpcsrcdir)/runxpcshelltests.py \
--test=$(SOLO_FILE) \
$(DIST)/bin/xpcshell \
$(topsrcdir) \
$(foreach dir,$(XPCSHELL_TESTS),$(testxpcobjdir)/$(MODULE)/$(dir))
endif # XPCSHELL_TESTS

View File

@ -1,38 +0,0 @@
/* ***** 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 mozilla.org code.
*
* The Initial Developer of the Original Code is
* Alexander J. Vincent <ajvincent@gmail.com>
*
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* 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 ***** */
_execute_test();

View File

@ -0,0 +1,159 @@
#!/usr/bin/env python
#
# ***** 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 mozilla.org code.
#
# The Initial Developer of the Original Code is The Mozilla Foundation
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ted Mielczarek <ted.mielczarek@gmail.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 ***** */
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):
"""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."""
xpcshell = os.path.abspath(xpcshell)
env = dict(os.environ)
env["NATIVE_TOPSRCDIR"] = os.path.normpath(topsrcdir)
env["TOPSRCDIR"] = topsrcdir
# Make assertions fatal
env["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
if xrePath is None:
xrePath = os.path.dirname(xpcshell)
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']
testharnessdir = os.path.dirname(os.path.abspath(sys.argv[0]))
headfiles = ['-f', os.path.join(testharnessdir, 'head.js')]
tailfiles = ['-f', os.path.join(testharnessdir, 'tail.js')]
if not interactive:
tailfiles += ['-e', '_execute_test();']
# when --test is specified, it can either be just a filename or
# 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]
for testdir in testdirs:
if singleDir and singleDir != os.path.basename(testdir):
continue
# get the list of head and tail files from the directory
testheadfiles = []
for f in glob(os.path.join(testdir, "head_*.js")):
if os.path.isfile(f):
testheadfiles += ['-f', f]
testtailfiles = []
for f in glob(os.path.join(testdir, "tail_*.js")):
if os.path.isfile(f):
testtailfiles += ['-f', f]
# now execute each test individually
# if a single test file was specified, we only want to execute that test
testfiles = glob(os.path.join(testdir, "test_*.js"))
if testFile:
if testFile in [os.path.basename(x) for x in testfiles]:
testfiles = [os.path.join(testdir, testFile)]
else: # not in this dir? skip it
continue
for test in testfiles:
pstdout = PIPE
pstderr = STDOUT
interactiveargs = []
if interactive:
pstdout = None
pstderr = None
interactiveargs = ['-e', 'print("To start the test, type _execute_test();")', '-i']
proc = Popen(args + headfiles + testheadfiles
+ ['-f', test]
+ tailfiles + testtailfiles + interactiveargs,
stdout=pstdout, stderr=pstderr, env=env)
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
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")
parser.add_option("--interactive",
action="store_true", dest="interactive", default=False,
help="don't automatically run tests, drop to an xpcshell prompt")
options, args = parser.parse_args()
if len(args) < 3:
print >>sys.stderr, "Usage: %s <path to xpcshell> <topsrcdir> <test dirs>" % 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):
sys.exit(1)
if __name__ == '__main__':
main()

View File

@ -1,132 +0,0 @@
#!/bin/bash
#
# vim:set ts=2 sw=2 sts=2 et:
#
# ***** 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 mozilla.org code.
#
# 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):
# 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
# 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 ***** */
# allow core dumps
ulimit -c 20480 2> /dev/null
# Make assertions fatal
XPCOM_DEBUG_BREAK=stack-and-abort; export XPCOM_DEBUG_BREAK
exit_status=0
##########################
# 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 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
###############################
# SETUP FOR RUNNING THE TESTS #
###############################
testxpcdir=$topsrcdir/testing/xpcshell
# 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 $testxpcdir/head.js"
for h in $testdir/head_*.js
do
if [ -f $h ]; then
headfiles="$headfiles -f $h"
fi
done
# files matching the pattern tail_*.js are treated like teardown files
# - they are run after tail.js
tailfiles="-f $testxpcdir/tail.js"
tailfiles="$tailfiles -f $testxpcdir/execute_test.js"
for t in $testdir/tail_*.js
do
if [ -f $t ]; then
tailfiles="$tailfiles -f $t"
fi
done
#################
# RUN EACH TEST #
#################
for t in $testdir/test_*.js
do
NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" $xpcshell -j -s $headfiles -f $t $tailfiles 2> $t.log 1>&2
rv="$?"
if [ ! "$rv" = "0" -o \
`grep -c '\*\*\* PASS' $t.log` = 0 ]
then
echo "TEST-UNEXPECTED-FAIL | $t | test failed, see log"
echo "$t.log:"
echo ">>>>>>>"
cat $t.log
echo ""
echo "<<<<<<<"
exit_status=1
else
echo "TEST-PASS | $t | all tests passed"
fi
done
exit $exit_status

View File

@ -1,159 +0,0 @@
#!/bin/bash
#
# vim:set ts=2 sw=2 sts=2 et:
#
# ***** 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 mozilla.org code.
#
# 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):
# Darin Fisher <darin@meer.net>
# Dave Liebreich <davel@mozilla.com>
# Jeff Walden <jwalden+code@mit.edu>
# Alexander J. Vincent <ajvincent@gmail.com> (single-test mode)
#
# 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 ***** */
# allow core dumps
ulimit -c 20480 2> /dev/null
# Make assertions fatal
XPCOM_DEBUG_BREAK=stack-and-abort; export XPCOM_DEBUG_BREAK
exit_status=0
# Launch a single test by calling:
# make SOLO_FILE=(filename) -C (test directory) check-one
# or
# make SOLO_FILE=(filename) -C (test directory) check-interactive
# js>_execute_test();
# js>quit();
##########################
# 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 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
# Get the actual JS test to run. Also get the directory it lives in, to load
# head and tail scripts.
target_js="$5"
target_dir=${target_js%/*}
if [ "$target_dir" == "$target_js" ] ; then
target_dir="unit";
else
target_dir_length=${#target_dir};
target_js=${target_js:$target_dir_length + 1};
fi
# Says if the test should be launch in interactive mode or not
interactive_mode="$6"
###############################
# SETUP FOR RUNNING THE TESTS #
###############################
testxpcdir=$topsrcdir/testing/xpcshell
# 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 $testxpcdir/head.js"
for h in $testdir/$target_dir/head_*.js
do
if [ -f $h ]; then
headfiles="$headfiles -f $h"
fi
done
# files matching the pattern tail_*.js are treated like teardown files
# - they are run after tail.js
tailfiles="-f $testxpcdir/tail.js"
if [ ! "$interactive_mode" = "1" ]; then
tailfiles="$tailfiles -f $testxpcdir/execute_test.js"
fi
for t in $testdir/$target_dir/tail_*.js
do
if [ -f $t ]; then
tailfiles="$tailfiles -f $t"
fi
done
############
# RUN TEST #
############
echo "NATIVE_TOPSRCDIR='$native_topsrcdir' TOPSRCDIR='$topsrcdir' $xpcshell -j -s $headfiles -f $testdir/$target_dir/$target_js $tailfiles 2>&1"
echo -n "$target_js: "
if [ ! "$interactive_mode" = "1" ]; then
NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" $xpcshell -j -s $headfiles -f $testdir/$target_dir/$target_js $tailfiles 2> $testdir/$target_dir/$target_js.log 1>&2
else
NATIVE_TOPSRCDIR="$native_topsrcdir" TOPSRCDIR="$topsrcdir" $xpcshell -j -s $headfiles -f $testdir/$target_dir/$target_js $tailfiles -i 2>&1
fi
rv="$?"
if [ ! "$rv" = "0" -o \
`grep -c '\*\*\* PASS' $testdir/$target_dir/$target_js.log` = 0 ]
then
echo "FAIL"
echo "$target_js.log:"
echo ">>>>>>>"
cat $testdir/$target_dir/$target_js.log
echo ""
echo "<<<<<<<"
exit_status=1
else
echo "PASS"
fi
exit $exit_status