Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
94 lines (77 sloc) 3.08 KB
#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at
import glob
import json
import os
import platform
import subprocess
import sys
import time
import stoneridge
class StoneRidgeRunner(object):
"""Does the actual work of running the stone ridge xpcshell tests
def __init__(self, tests=None, heads=None):
"""tests - a subset of the tests to run
heads - js files that provide extra functionality
# These we just copy over and worry about them later
self.tests = tests
self.heads = heads if heads else []
def _build_testlist(self):
"""Return a list of test file names, all relative to the test root.
This weeds out any tests that may be missing from the directory.
if not self.tests:
return [os.path.basename(f) for f in
glob.glob(os.path.join(stoneridge.testroot, '*.js'))]
tests = []
for candidate in self.tests:
if not candidate.endswith('.js'):
sys.stdout.write('### INVALID TEST %s\n' % (candidate,))
elif not os.path.exists(os.path.join(stoneridge.testroot, candidate)):
sys.stdout.write('### MISSING TEST %s\n' % (candidate,))
return tests
def _build_preargs(self):
"""Build the list of arguments (including head js files) for everything
except the actual command to run.
preargs = ['-v', '180']
for head in self.heads:
abshead = os.path.abspath(head)
preargs.extend(['-f', abshead])
return preargs
def run(self):
tests = self._build_testlist()
preargs = self._build_preargs()
# Ensure our output directory exists
except OSError:
for test in tests:
outfile = '%s.out' % (test,)
args = preargs + [
'-e', 'const _SR_OUT_SUBDIR = "%s";' % (stoneridge.xpcoutleaf,),
'-e', 'const _SR_OUT_FILE = "%s";' % (outfile,),
'-f', os.path.join(stoneridge.installroot, 'head.js'),
'-f', os.path.join(stoneridge.testroot, test),
'-e', 'do_stoneridge(); quit(0);'
res, _ = stoneridge.run_xpcshell(args, stdout=sys.stdout)
if res:
sys.stdout.write('### TEST FAIL: %s\n' % (test,))
def main():
parser = stoneridge.ArgumentParser()
parser.add_argument('--head', dest='heads', action='append', metavar='HEADFILE',
help='Extra head.js file to append (can be used more than once)')
parser.add_argument('tests', nargs='*', metavar='TEST',
help='Name of single test file to run')
args = parser.parse_args()
runner = StoneRidgeRunner(args.tests, args.heads)
Jump to Line
Something went wrong with that request. Please try again.