Chromium Code Reviews| 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..7b153bcefc84007d876dec5730b0c48d60d7c50b |
| --- /dev/null |
| +++ b/mojo/tools/run_pure_go_tests.py |
| @@ -0,0 +1,47 @@ |
| +#!/usr/bin/env python |
| +# Copyright (c) 2015 The Chromium Authors. All rights reserved. |
|
viettrungluu
2015/10/05 23:16:59
The current copyright does not have the "(c)".
rudominer
2015/10/06 00:29:10
Done.
|
| +# 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)) |
| + |
| + saved_cwd = os.getcwd() |
|
viettrungluu
2015/10/05 23:16:59
Why do you bother doing this?
rudominer
2015/10/06 00:29:10
Good point. Removed.
|
| + # 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. |
|
viettrungluu
2015/10/05 23:16:59
It seems like a bad idea to hard-code stuff in a s
rudominer
2015/10/06 00:29:10
OK. What do you think about the following strategy
viettrungluu
2015/10/06 01:46:30
SGTM
|
| + # NOTE(rudominer) The paths should all be made absolute by including |
| + # 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 ) |
| + return call_result |
| + |
| + os.chdir(saved_cwd) |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |