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 | |
6 import argparse | |
7 import os | |
8 import subprocess | |
9 import sys | |
10 | |
11 from mopy.paths import Paths | |
12 | |
13 | |
14 def main(): | |
15 parser = argparse.ArgumentParser(description="Runs pure Go tests in the " | |
16 "Mojo source tree from a list of directories specified in a data file.") | |
17 parser.add_argument('go_tool_path', metavar='go-tool-path', | |
18 help="the path to the 'go' binary") | |
19 parser.add_argument("test_list_file", type=file, metavar='test-list-file', | |
20 help="a file listing directories containing go tests " | |
21 "to run") | |
22 args = parser.parse_args() | |
23 go_tool = args.go_tool_path | |
24 env = os.environ.copy() | |
25 env['GOROOT'] = os.path.dirname(os.path.dirname(go_tool)) | |
26 | |
27 # Execute the Python script specified in args.test_list_file. | |
28 # This will populate a list of Go directories. | |
29 test_list_globals = {} | |
30 exec args.test_list_file in test_list_globals | |
31 test_dirs = test_list_globals["test_dirs"] | |
32 | |
33 src_root = Paths().src_root | |
34 assert os.path.isabs(src_root) | |
35 # |test_dirs| is a list of lists. Each sublist contains the components of a | |
36 # path, relative to |src_root|, of a directory containing a Go package. | |
37 for test_dir_path_components in test_dirs: | |
38 test_dir = os.path.join(src_root, *test_dir_path_components) | |
39 os.chdir(test_dir) | |
40 print "Running Go tests in %s..." % test_dir | |
41 return subprocess.call([go_tool, "test"], env=env) | |
rudominer
2015/10/09 18:30:30
This return was a bug introduced in an earlier pat
| |
42 | |
43 if __name__ == '__main__': | |
44 sys.exit(main()) | |
OLD | NEW |