Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: mojo/tools/run_pure_go_tests.py

Issue 1384243002: Adds the ability to run pure Go unit tests in the Mojo test suite. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Further code review comment responses. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« mojo/tools/get_test_list.py ('K') | « mojo/tools/get_test_list.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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())
OLDNEW
« mojo/tools/get_test_list.py ('K') | « mojo/tools/get_test_list.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698