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..1d82f51932e8e70fb97dcb3066e0bccabc6304af |
--- /dev/null |
+++ b/mojo/tools/run_pure_go_tests.py |
@@ -0,0 +1,48 @@ |
+#!/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. |
+ |
viettrungluu
2015/10/09 21:39:49
Needs a file-level docstring.
rudominer
2015/10/09 23:42:07
Done.
|
+import argparse |
+import os |
+import subprocess |
+import sys |
+ |
+from mopy.paths import Paths |
+ |
+src_root = Paths().src_root |
+ |
+sys.path.append(os.path.join(src_root, 'mojo')) |
+from go.go import InvokeGo |
+ |
+ |
+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 |
+ |
+ # 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"] |
+ |
+ assert os.path.isabs(src_root) |
+ # |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 |
+ call_result = InvokeGo(go_tool, ["test"]) |
+ if call_result: |
+ return call_result |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |