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

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: Responds to code review commnets. 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..d56d62d4f9ffa9c1d0fe06c0900e3f7b20c82b5b
--- /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 hard-coded list of directories.")
+ parser.add_argument('go_tool_path', metavar='go-tool-path',
+ help="the path to the 'go' binary")
+ args = parser.parse_args()
+ go_tool = args.go_tool_path
+ env = os.environ.copy()
+ env['GOROOT'] = os.path.dirname(os.path.dirname(go_tool))
viettrungluu 2015/10/06 01:46:30 Maybe it should take the Go root as an argument in
viettrungluu 2015/10/06 21:08:06 You didn't say anything about this.
rudominer 2015/10/09 18:30:30 I'm sorry I missed this comment. I took your secon
+
+ # TODO(rudominer) Uncomment the line below when we are able to make use of
+ # the src_root variable.
+ # src_root = Paths().src_root
+
+ test_dir_list = [
+ # TODO(rudominer) Add paths to go directories with tests.
+ # NOTE(rudominer) The paths should all be made absolute by including
ppi 2015/10/06 17:57:47 This will be better enforced by assert on os.path.
rudominer 2015/10/06 20:28:54 This is now organized differently.
+ # src_root as the first path component.
+ # os.path.join(src_root, 'mojom', 'mojom_parser', 'lexer'),
+ ]
+
+ for test_dir in test_dir_list:
+ os.chdir(test_dir)
+ print "Running Go tests in %s..." % test_dir
+ call_result = subprocess.call([go_tool, "test"], env=env)
+ if call_result:
+ os.chdir(saved_cwd )
ppi 2015/10/06 17:57:46 Need to drop this line too.
rudominer 2015/10/06 20:28:54 Thanks. Done.
+ return call_result
+
+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