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..3ed0765340d7e6254b71c5b61da180351918dd60 |
--- /dev/null |
+++ b/mojo/tools/run_pure_go_tests.py |
@@ -0,0 +1,44 @@ |
+#!/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 |
+ 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 |
+ 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
|
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |