OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Runs pure Go tests in the Mojo source tree from a list of directories |
| 7 specified in a data file.""" |
| 8 |
| 9 |
| 10 import argparse |
| 11 import os |
| 12 import subprocess |
| 13 import sys |
| 14 |
| 15 from mopy.invoke_go import InvokeGo |
| 16 from mopy.paths import Paths |
| 17 |
| 18 |
| 19 def main(): |
| 20 parser = argparse.ArgumentParser(description="Runs pure Go tests in the " |
| 21 "Mojo source tree from a list of directories specified in a data file.") |
| 22 parser.add_argument('go_tool_path', metavar='go-tool-path', |
| 23 help="the path to the 'go' binary") |
| 24 parser.add_argument("test_list_file", type=file, metavar='test-list-file', |
| 25 help="a file listing directories containing go tests " |
| 26 "to run") |
| 27 args = parser.parse_args() |
| 28 go_tool = args.go_tool_path |
| 29 |
| 30 # Execute the Python script specified in args.test_list_file. |
| 31 # This will populate a list of Go directories. |
| 32 test_list_globals = {} |
| 33 exec args.test_list_file in test_list_globals |
| 34 test_dirs = test_list_globals["test_dirs"] |
| 35 |
| 36 src_root = Paths().src_root |
| 37 assert os.path.isabs(src_root) |
| 38 # |test_dirs| is a list of "/"-delimited, |src_root|-relative, paths |
| 39 # of directories containing a Go package. |
| 40 for path in test_dirs: |
| 41 test_dir = os.path.join(src_root, *path.split('/')) |
| 42 os.chdir(test_dir) |
| 43 print "Running Go tests in %s..." % test_dir |
| 44 call_result = InvokeGo(go_tool, ["test"]) |
| 45 if call_result: |
| 46 return call_result |
| 47 |
| 48 if __name__ == '__main__': |
| 49 sys.exit(main()) |
OLD | NEW |