OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Host driven test server controller. | 5 """Host driven test server controller. |
6 | 6 |
7 This class controls the startup and shutdown of a python driven test server that | 7 This class controls the startup and shutdown of a python driven test server that |
8 runs in a separate process. | 8 runs in a separate process. |
9 | 9 |
10 The server starts up automatically when the object is created. | 10 The server starts up automatically when the object is created. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 member variable |port|. | 63 member variable |port|. |
64 test_server_path: The path (relative to the root src dir) of the server | 64 test_server_path: The path (relative to the root src dir) of the server |
65 """ | 65 """ |
66 self.host = _TEST_SERVER_HOST | 66 self.host = _TEST_SERVER_HOST |
67 self.port = test_server_port + shard_index | 67 self.port = test_server_port + shard_index |
68 | 68 |
69 src_dir = constants.DIR_SOURCE_ROOT | 69 src_dir = constants.DIR_SOURCE_ROOT |
70 # Make dirs into a list of absolute paths. | 70 # Make dirs into a list of absolute paths. |
71 abs_dirs = [os.path.join(src_dir, d) for d in _PYTHONPATH_DIRS] | 71 abs_dirs = [os.path.join(src_dir, d) for d in _PYTHONPATH_DIRS] |
72 # Add the generated python files to the path | 72 # Add the generated python files to the path |
73 abs_dirs.extend([os.path.join(src_dir, 'out', constants.GetBuildType(), d) | 73 abs_dirs.extend([os.path.join(src_dir, constants.GetOutDirectory(), d) |
74 for d in _GENERATED_PYTHONPATH_DIRS]) | 74 for d in _GENERATED_PYTHONPATH_DIRS]) |
75 current_python_path = os.environ.get('PYTHONPATH') | 75 current_python_path = os.environ.get('PYTHONPATH') |
76 extra_python_path = ':'.join(abs_dirs) | 76 extra_python_path = ':'.join(abs_dirs) |
77 if current_python_path: | 77 if current_python_path: |
78 python_path = current_python_path + ':' + extra_python_path | 78 python_path = current_python_path + ':' + extra_python_path |
79 else: | 79 else: |
80 python_path = extra_python_path | 80 python_path = extra_python_path |
81 | 81 |
82 # NOTE: A separate python process is used to simplify getting the right | 82 # NOTE: A separate python process is used to simplify getting the right |
83 # system path for finding includes. | 83 # system path for finding includes. |
84 cmd = ['python', os.path.join(src_dir, test_server_path), | 84 cmd = ['python', os.path.join(src_dir, test_server_path), |
85 '--log-to-console', | 85 '--log-to-console', |
86 ('--host=%s' % self.host), | 86 ('--host=%s' % self.host), |
87 ('--port=%d' % self.port)] | 87 ('--port=%d' % self.port)] |
88 self._test_server_process = subprocess.Popen( | 88 self._test_server_process = subprocess.Popen( |
89 cmd, env={'PYTHONPATH': python_path}) | 89 cmd, env={'PYTHONPATH': python_path}) |
90 | 90 |
91 def TearDown(self): | 91 def TearDown(self): |
92 self._test_server_process.kill() | 92 self._test_server_process.kill() |
OLD | NEW |