-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·72 lines (61 loc) · 2.31 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
import argparse
import os
from os.path import abspath, join, dirname, splitext
import sys
import time
sys.path.insert(0, abspath(join(dirname(__file__), "common")))
import shelltest, test_framework, unit, utils
tests = None
# helper function for loading tests from full_test/*.test
def generate_test(tree):
def gen(test_command, name):
i = 1
new_name = name
while tree.has_test(new_name):
i = i + 1
new_name = name + '-' + str(i)
tree[new_name] = shelltest.ShellCommandTest(test_command)
return gen
# load the tests from full_test/*.test
def load_tests():
dirpath = join(dirname(__file__), "full_test")
for filename in os.listdir(dirpath):
base_name, ext = splitext(filename)
if ext == '.test':
tree = test_framework.TestTree();
full_path = os.path.join(dirpath, filename)
execfile(full_path, {"__builtins__": __builtins__, "generate_test": generate_test(tree)})
tests.add(base_name, tree)
# Test groups
groups = {}
# Load the test groups from full_test/*.group
def load_groups():
dirpath = join(dirname(__file__), "full_test")
for filename in os.listdir(dirpath):
base_name, ext = splitext(filename)
if ext == '.group':
full_path = os.path.join(dirpath, filename)
groups[base_name] = test_framework.group_from_file(full_path)
# Take the requirements for the tests, and build a configuration
def configure(reqs, args):
src_root = utils.project_root_dir
if args.build_dir:
build_dir = args.build_dir
else:
build_dir = utils.latest_build_dir()
return dict(SRC_ROOT=src_root, BUILD_DIR=build_dir)
if __name__ == '__main__':
# Initialise the list of tests with the dumy tests and the unit tests
tests = test_framework.TestTree({
'unit': unit.AllUnitTests()
})
argparser = argparse.ArgumentParser(parents=[test_framework.argparser])
argparser.add_argument('-b', '--build-dir', default=None,
help='The rethinkdb build directory (Default: the latest one)')
args = argparser.parse_args(sys.argv[1:])
load_tests()
load_groups()
ret = test_framework.run(tests, groups, lambda reqs: configure(reqs, args), args)
if ret is not None:
sys.exit(1)