Commit 4549b9cc authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Gather all tests at once, rather than doing them directory by directory

This increases the parallelism possible, and allows us to track what
progress we are making.
parent ecea053e
......@@ -77,9 +77,6 @@ for opt,arg in opts:
if opt == '--output-summary':
config.output_summary = arg
if opt == '--times-file':
config.times_file = arg
if opt == '--only':
config.only.append(arg)
......@@ -169,38 +166,32 @@ print 'Beginning test run at', t.start_time
sys.stdout.flush()
sys.stdout = os.fdopen(sys.__stdout__.fileno(), "w", 0)
times = {}
# First collect all the tests to be run
for file in t_files:
print '====> Running', file
print '====> Scanning', file
newTestDir(os.path.dirname(file))
try:
if config.use_threads:
t.running_threads=0
start = time.time()
execfile(file)
end = time.time()
times[file] = end - start
if config.use_threads:
t.thread_pool.acquire()
while t.running_threads>0:
t.thread_pool.wait()
t.thread_pool.release()
except:
print '*** framework failure: found an error while executing ', file, ':'
t.n_framework_failures = t.n_framework_failures + 1
traceback.print_exc()
# Now run all the tests
if config.use_threads:
t.running_threads=0
for oneTest in allTests:
oneTest()
if config.use_threads:
t.thread_pool.acquire()
while t.running_threads>0:
t.thread_pool.wait()
t.thread_pool.release()
summary(t, sys.stdout)
if config.output_summary != '':
summary(t, open(config.output_summary, 'w'))
if config.times_file != '':
h = open(config.times_file, 'w')
for (k, v) in times.items():
h.write(k + ',' + str(v) + '\n')
h.close()
sys.exit(0)
......@@ -205,6 +205,9 @@ class TestOptions:
# Extra output normalisation
self.extra_normaliser = lambda x: x
# The directory the test is in
self.testdir = '.'
# The default set of options
global default_testopts
default_testopts = TestOptions()
......
......@@ -374,26 +374,19 @@ def _compose( opts, f, g ):
# -----------------------------------------------------------------------------
# The current directory of tests
global testdir
testdir = '.'
def newTestDir( dir ):
global testdir, thisdir_testopts
testdir = dir
global thisdir_testopts
# reset the options for this test directory
thisdir_testopts = copy.copy(default_testopts)
def getTestDir():
return testdir
thisdir_testopts.testdir = dir
# -----------------------------------------------------------------------------
# Actually doing tests
# name :: String
# setup :: TestOpts -> IO ()
def test ( name, setup, func, args):
allTests = []
def runTest (opts, name, setup, func, args):
n = 1
opts = copy.copy(thisdir_testopts)
if type(setup) is types.ListType:
setup = composes(setup)
......@@ -420,6 +413,13 @@ def test ( name, setup, func, args):
else:
test_common_work (name, opts, func, args)
# name :: String
# setup :: TestOpts -> IO ()
def test (name, setup, func, args):
global allTests
myTestOpts = copy.copy(thisdir_testopts)
allTests += [lambda : runTest(myTestOpts, name, setup, func, args)]
if config.use_threads:
def test_common_thread(n, name, opts, func, args):
t.lock.acquire()
......@@ -748,7 +748,7 @@ def simple_build( name, way, extra_hc_opts, should_fail, top_mod, link ):
if opts.compiler_stats_num_fields != []:
extra_hc_opts += ' +RTS -V0 -t' + stats_file + ' --machine-readable -RTS'
cmd = 'cd ' + testdir + " && '" \
cmd = 'cd ' + getTestOpts().testdir + " && '" \
+ config.compiler + "' " \
+ join(config.compiler_always_flags,' ') + ' ' \
+ to_do + ' ' + srcname + ' ' \
......@@ -819,7 +819,7 @@ def simple_run( name, way, prog, args ):
stdin_comes_from = ''
else:
stdin_comes_from = ' <' + use_stdin
cmd = 'cd ' + testdir + ' && ' \
cmd = 'cd ' + getTestOpts().testdir + ' && ' \
+ prog + ' ' + args + ' ' \
+ my_rts_flags + ' ' \
+ stdin_comes_from \
......@@ -926,7 +926,7 @@ def interpreter_run( name, way, extra_hc_opts, compile_only, top_mod ):
script.close()
cmd = 'cd ' + testdir + " && " + cmd_prefix + "'" \
cmd = 'cd ' + getTestOpts().testdir + " && " + cmd_prefix + "'" \
+ config.compiler + "' " \
+ join(config.compiler_always_flags,' ') + ' ' \
+ srcname + ' ' \
......@@ -1015,7 +1015,7 @@ def extcore_run( name, way, extra_hc_opts, compile_only, top_mod ):
else:
to_do = ' --make ' + top_mod + ' '
cmd = 'cd ' + testdir + " && '" \
cmd = 'cd ' + getTestOpts().testdir + " && '" \
+ config.compiler + "' " \
+ join(config.compiler_always_flags,' ') + ' ' \
+ join(config.way_flags[way],' ') + ' ' \
......@@ -1045,7 +1045,7 @@ def extcore_run( name, way, extra_hc_opts, compile_only, top_mod ):
flags = join(filter(lambda f: f != '-fext-core',config.way_flags[way]),' ')
cmd = 'cd ' + testdir + " && '" \
cmd = 'cd ' + getTestOpts().testdir + " && '" \
+ config.compiler + "' " \
+ join(config.compiler_always_flags,' ') + ' ' \
+ to_compile + ' ' \
......@@ -1132,7 +1132,7 @@ def write_file(file, str):
def check_hp_ok(name):
# do not qualify for hp2ps because we should be in the right directory
hp2psCmd = 'cd ' + testdir + ' && ' + config.hp2ps + ' ' + name
hp2psCmd = 'cd ' + getTestOpts().testdir + ' && ' + config.hp2ps + ' ' + name
hp2psResult = runCmdExitCode(hp2psCmd)
......@@ -1358,7 +1358,7 @@ def add_hs_lhs_suffix(name):
return add_suffix(name, 'hs')
def in_testdir( name ):
return (testdir + '/' + name)
return (getTestOpts().testdir + '/' + name)
def qualify( name, suff ):
return in_testdir(add_suffix(name, suff))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment