Index: mojo/tools/run_pure_go_tests.py |
diff --git a/mojo/tools/run_pure_go_tests.py b/mojo/tools/run_pure_go_tests.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..b1045f0193e0ba3306400df722e1ba29956f33f5 |
--- /dev/null |
+++ b/mojo/tools/run_pure_go_tests.py |
@@ -0,0 +1,43 @@ |
+#!/usr/bin/env python |
+# Copyright 2015 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import argparse |
+import os |
+import subprocess |
+import sys |
+ |
+from mopy.paths import Paths |
+ |
+ |
+def main(): |
+ parser = argparse.ArgumentParser(description="Runs pure Go tests in the " |
+ "Mojo source tree from a list of directories specified in a data file.") |
+ parser.add_argument('go_tool_path', metavar='go-tool-path', |
+ help="the path to the 'go' binary") |
+ parser.add_argument("test_list_file", type=file, metavar='test-list-file', |
+ help="a file listing directories containing go tests " |
+ "to run") |
+ args = parser.parse_args() |
+ go_tool = args.go_tool_path |
+ env = os.environ.copy() |
+ env['GOROOT'] = os.path.dirname(os.path.dirname(go_tool)) |
+ |
+ # Execute the Python script specified in args.test_list_file. |
+ # This will populate a list of Go directories. |
+ test_list_globals = {} |
+ exec args.test_list_file in test_list_globals |
+ test_dirs = test_list_globals["test_dirs"] |
+ |
+ src_root = Paths().src_root |
ppi
2015/10/06 20:33:27
We'd still probably want to assert os.path.isabs(s
rudominer
2015/10/06 20:52:41
Done.
|
+ # |test_dirs| is a list of lists. Each sublist contains the components of a |
+ # path, relative to |src_root|, of a directory containing a Go package. |
+ for test_dir_path_components in test_dirs: |
+ test_dir = os.path.join(src_root, *test_dir_path_components) |
+ os.chdir(test_dir) |
+ print "Running Go tests in %s..." % test_dir |
+ return subprocess.call([go_tool, "test"], env=env) |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |