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
|
#!/usr/bin/python
'''Script to attempt an isolated build of the C++ driver and its examples.
Working directory must be the repository root.
Usage:
./buildscripts/build_and_test_client.py <mongo client archive file> [optional scons arguments]
The client is built in a temporary directory, and the sample programs are run against a mongod
instance found in the current working directory. The temporary directory and its contents are
destroyed at the end of execution.
'''
import os
import shutil
import subprocess
import sys
import tempfile
import tarfile
import utils
def main(args):
archive_file = args[1]
scons_args = args[2:]
build_and_test(archive_file, scons_args)
def build_and_test(archive, scons_args):
work_dir = tempfile.mkdtemp()
try:
extracted_root = extract_archive(work_dir, archive)
run_scons(extracted_root, scons_args)
smoke_client(extracted_root)
finally:
shutil.rmtree(work_dir)
def extract_archive(work_dir, archive):
tf = tarfile.open(archive, 'r')
tf.extractall(path=work_dir)
return os.path.join(
work_dir,
os.path.dirname([n for n in tf.getnames() if n.endswith('SConstruct')][0])
)
def run_scons(extracted_root, scons_args):
rc = subprocess.call(['scons', '-C', extracted_root, ] + scons_args + ['clientTests'])
if rc is not 0:
sys.exit(rc)
def smoke_client(extracted_root):
rc = subprocess.call(utils.smoke_command("--test-path", extracted_root, "client"))
if rc is not 0:
sys.exit(rc)
if __name__ == '__main__':
main(sys.argv)
sys.exit(0)
|