Skip to content
Snippets Groups Projects
Commit b50d1666 authored by Craig Tiller's avatar Craig Tiller
Browse files

Make run_tests.py pass lint

parent 71735185
No related branches found
No related tags found
No related merge requests found
...@@ -4,16 +4,18 @@ ...@@ -4,16 +4,18 @@
import argparse import argparse
import glob import glob
import itertools import itertools
import simplejson
import multiprocessing import multiprocessing
import sys import sys
import time import time
import jobset import jobset
import simplejson
import watch_dirs import watch_dirs
# SimpleConfig: just compile with CONFIG=config, and run the binary to test # SimpleConfig: just compile with CONFIG=config, and run the binary to test
class SimpleConfig(object): class SimpleConfig(object):
def __init__(self, config): def __init__(self, config):
self.build_config = config self.build_config = config
self.maxjobs = 32 * multiprocessing.cpu_count() self.maxjobs = 32 * multiprocessing.cpu_count()
...@@ -24,6 +26,7 @@ class SimpleConfig(object): ...@@ -24,6 +26,7 @@ class SimpleConfig(object):
# ValgrindConfig: compile with some CONFIG=config, but use valgrind to run # ValgrindConfig: compile with some CONFIG=config, but use valgrind to run
class ValgrindConfig(object): class ValgrindConfig(object):
def __init__(self, config, tool): def __init__(self, config, tool):
self.build_config = config self.build_config = config
self.tool = tool self.tool = tool
...@@ -35,15 +38,15 @@ class ValgrindConfig(object): ...@@ -35,15 +38,15 @@ class ValgrindConfig(object):
# different configurations we can run under # different configurations we can run under
_CONFIGS = { _CONFIGS = {
'dbg': SimpleConfig('dbg'), 'dbg': SimpleConfig('dbg'),
'opt': SimpleConfig('opt'), 'opt': SimpleConfig('opt'),
'tsan': SimpleConfig('tsan'), 'tsan': SimpleConfig('tsan'),
'msan': SimpleConfig('msan'), 'msan': SimpleConfig('msan'),
'asan': SimpleConfig('asan'), 'asan': SimpleConfig('asan'),
'gcov': SimpleConfig('gcov'), 'gcov': SimpleConfig('gcov'),
'memcheck': ValgrindConfig('valgrind', 'memcheck'), 'memcheck': ValgrindConfig('valgrind', 'memcheck'),
'helgrind': ValgrindConfig('dbg', 'helgrind') 'helgrind': ValgrindConfig('dbg', 'helgrind')
} }
_DEFAULT = ['dbg', 'opt'] _DEFAULT = ['dbg', 'opt']
...@@ -87,6 +90,8 @@ forever = args.forever ...@@ -87,6 +90,8 @@ forever = args.forever
class TestCache(object): class TestCache(object):
"""Cache for running tests."""
def __init__(self): def __init__(self):
self._last_successful_run = {} self._last_successful_run = {}
...@@ -102,7 +107,8 @@ class TestCache(object): ...@@ -102,7 +107,8 @@ class TestCache(object):
self._last_successful_run[' '.join(cmdline)] = bin_hash self._last_successful_run[' '.join(cmdline)] = bin_hash
def dump(self): def dump(self):
return [{'cmdline': k, 'hash': v} for k, v in self._last_successful_run.iteritems()] return [{'cmdline': k, 'hash': v}
for k, v in self._last_successful_run.iteritems()]
def parse(self, exdump): def parse(self, exdump):
self._last_successful_run = dict((o['cmdline'], o['hash']) for o in exdump) self._last_successful_run = dict((o['cmdline'], o['hash']) for o in exdump)
...@@ -138,19 +144,19 @@ def _build_and_run(check_cancelled, newline_on_success, cache): ...@@ -138,19 +144,19 @@ def _build_and_run(check_cancelled, newline_on_success, cache):
glob.glob('bins/%s/%s_test' % ( glob.glob('bins/%s/%s_test' % (
config.build_config, filt)), config.build_config, filt)),
runs_per_test)))), runs_per_test)))),
check_cancelled, check_cancelled,
newline_on_success=newline_on_success, newline_on_success=newline_on_success,
maxjobs=min(c.maxjobs for c in run_configs), maxjobs=min(c.maxjobs for c in run_configs),
cache=cache): cache=cache):
return 2 return 2
return 0 return 0
test_cache = (None if runs_per_test != 1 test_cache = (None if runs_per_test != 1
or 'gcov' in build_configs or 'gcov' in build_configs
or 'valgrind' in build_configs or 'valgrind' in build_configs
else TestCache()) else TestCache())
if test_cache: if test_cache:
test_cache.load() test_cache.load()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment