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

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: 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..af24a3ee49a1a07b14d8cbfe72aa75018e9b4ecb
--- /dev/null
+++ b/mojo/tools/run_pure_go_tests.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+# Copyright (c) 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
+
ppi 2015/10/05 21:49:58 I think the style guide wants two empty lines here
rudominer 2015/10/05 23:08:13 Done. But now the two empty lines are lines 12 and
+def main():
+ parser = argparse.ArgumentParser()
ppi 2015/10/05 21:49:58 Please add a desription string, ie. argparse.Argum
rudominer 2015/10/05 23:08:13 Done.
+ parser.add_argument('--go_tool')
ppi 2015/10/05 21:49:58 I think we prefer "dash-only" arguments: --go-tool
ppi 2015/10/05 21:49:58 If that is a required argument I'd make it positio
rudominer 2015/10/05 23:08:12 Done.
rudominer 2015/10/05 23:08:13 Done.
rudominer 2015/10/05 23:08:13 Done.
+ args = parser.parse_args()
+ go_tool = args.go_tool
+ assert go_tool is not None
+ env = os.environ.copy()
+ env['GOROOT'] = os.path.dirname(os.path.dirname(go_tool))
+
+ saved_cwd = os.getcwd()
+
+ test_dir_list = [
+ # TODO(rudominer) Add paths to go directories with tests.
+ #os.path.join('mojom', 'mojom_parser', 'lexer'),
+ ]
+
+ for test_dir in test_dir_list:
+ os.chdir(test_dir)
ppi 2015/10/05 21:49:58 There is an issue here that as "test_dir" is relat
rudominer 2015/10/05 23:08:13 Thank you for catching this. I went with your opti
+ print "Running Go tests in %s..." % test_dir
+ call_result = subprocess.call([go_tool, "test"], env=env)
+ if call_result:
+ os.chdir(saved_cwd )
+ return call_result
+
+ os.chdir(saved_cwd )
ppi 2015/10/05 21:49:58 remove the space after "saved_cwd".
rudominer 2015/10/05 23:08:13 Done.
+
+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