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

Unified 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: Specify pats to directories in a data file. Plus other fixes. 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 side-by-side diff with in-line comments
Download patch
« mojo/tools/get_test_list.py ('K') | « mojo/tools/get_test_list.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« 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