OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
viettrungluu
2015/10/09 21:39:49
Needs a file-level docstring.
rudominer
2015/10/09 23:42:07
Done.
| |
6 import argparse | |
7 import os | |
8 import subprocess | |
9 import sys | |
10 | |
11 from mopy.paths import Paths | |
12 | |
13 src_root = Paths().src_root | |
14 | |
15 sys.path.append(os.path.join(src_root, 'mojo')) | |
16 from go.go import InvokeGo | |
17 | |
18 | |
19 def main(): | |
20 parser = argparse.ArgumentParser(description="Runs pure Go tests in the " | |
21 "Mojo source tree from a list of directories specified in a data file.") | |
22 parser.add_argument('go_tool_path', metavar='go-tool-path', | |
23 help="the path to the 'go' binary") | |
24 parser.add_argument("test_list_file", type=file, metavar='test-list-file', | |
25 help="a file listing directories containing go tests " | |
26 "to run") | |
27 args = parser.parse_args() | |
28 go_tool = args.go_tool_path | |
29 | |
30 # Execute the Python script specified in args.test_list_file. | |
31 # This will populate a list of Go directories. | |
32 test_list_globals = {} | |
33 exec args.test_list_file in test_list_globals | |
34 test_dirs = test_list_globals["test_dirs"] | |
35 | |
36 assert os.path.isabs(src_root) | |
37 # |test_dirs| is a list of lists. Each sublist contains the components of a | |
38 # path, relative to |src_root|, of a directory containing a Go package. | |
39 for test_dir_path_components in test_dirs: | |
40 test_dir = os.path.join(src_root, *test_dir_path_components) | |
41 os.chdir(test_dir) | |
42 print "Running Go tests in %s..." % test_dir | |
43 call_result = InvokeGo(go_tool, ["test"]) | |
44 if call_result: | |
45 return call_result | |
46 | |
47 if __name__ == '__main__': | |
48 sys.exit(main()) | |
OLD | NEW |