| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Setups a local Rietveld instance to test against a live server for | 6 """Setups a local Rietveld instance to test against a live server for |
| 7 integration tests. | 7 integration tests. |
| 8 | 8 |
| 9 It makes sure Google AppEngine SDK is found, download Rietveld and Django code | 9 It makes sure Google AppEngine SDK is found, download Rietveld and Django code |
| 10 if necessary and starts the server on a free inbound TCP port. | 10 if necessary and starts the server on a free inbound TCP port. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 class LocalRietveld(object): | 43 class LocalRietveld(object): |
| 44 """Downloads everything needed to run a local instance of Rietveld.""" | 44 """Downloads everything needed to run a local instance of Rietveld.""" |
| 45 | 45 |
| 46 def __init__(self, base_dir=None): | 46 def __init__(self, base_dir=None): |
| 47 # Paths | 47 # Paths |
| 48 self.base_dir = base_dir | 48 self.base_dir = base_dir |
| 49 if not self.base_dir: | 49 if not self.base_dir: |
| 50 self.base_dir = os.path.dirname(os.path.abspath(__file__)) | 50 self.base_dir = os.path.dirname(os.path.abspath(__file__)) |
| 51 self.base_dir = os.path.realpath(os.path.join(self.base_dir, '..')) | 51 self.base_dir = os.path.realpath(os.path.join(self.base_dir, '..')) |
| 52 self.sdk_path = os.path.abspath( | 52 self.sdk_path = os.path.abspath( |
| 53 os.path.join(self.base_dir, '..', '..', 'google_appengine')) | 53 os.path.join(self.base_dir, '..', 'google_appengine')) |
| 54 self.dev_app = os.path.join(self.sdk_path, 'dev_appserver.py') | 54 self.dev_app = os.path.join(self.sdk_path, 'dev_appserver.py') |
| 55 self.rietveld = os.path.join(self.base_dir, 'test', 'rietveld') | 55 self.rietveld = os.path.join(self.base_dir, 'tests', 'rietveld') |
| 56 self.test_server = None | 56 self.test_server = None |
| 57 self.port = None | 57 self.port = None |
| 58 # Generate a friendly environment. | 58 # Generate a friendly environment. |
| 59 self.env = os.environ.copy() | 59 self.env = os.environ.copy() |
| 60 self.env['LANGUAGE'] = 'en' | 60 self.env['LANGUAGE'] = 'en' |
| 61 self.out = None | 61 self.out = None |
| 62 self.err = None | 62 self.err = None |
| 63 | 63 |
| 64 def install_prerequisites(self): | 64 def install_prerequisites(self): |
| 65 # First, verify the Google AppEngine SDK is available. | 65 # First, verify the Google AppEngine SDK is available. |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 instance.start_server(verbose=options.verbose) | 137 instance.start_server(verbose=options.verbose) |
| 138 print 'Local rietveld instance started on port %d' % instance.port | 138 print 'Local rietveld instance started on port %d' % instance.port |
| 139 while True: | 139 while True: |
| 140 time.sleep(0.1) | 140 time.sleep(0.1) |
| 141 finally: | 141 finally: |
| 142 instance.stop_server() | 142 instance.stop_server() |
| 143 | 143 |
| 144 | 144 |
| 145 if __name__ == '__main__': | 145 if __name__ == '__main__': |
| 146 main() | 146 main() |
| OLD | NEW |