| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 try: | 100 try: |
| 101 subprocess2.check_call( | 101 subprocess2.check_call( |
| 102 ['hg', 'co', '-q', '-C', rev], cwd=self.rietveld) | 102 ['hg', 'co', '-q', '-C', rev], cwd=self.rietveld) |
| 103 except (OSError, subprocess2.CalledProcessError), e: | 103 except (OSError, subprocess2.CalledProcessError), e: |
| 104 raise Failure('Failed to sync rietveld\n%s' % e) | 104 raise Failure('Failed to sync rietveld\n%s' % e) |
| 105 | 105 |
| 106 def start_server(self, verbose=False): | 106 def start_server(self, verbose=False): |
| 107 self.install_prerequisites() | 107 self.install_prerequisites() |
| 108 assert not self.tempdir | 108 assert not self.tempdir |
| 109 self.tempdir = tempfile.mkdtemp(prefix='rietveld_test') | 109 self.tempdir = tempfile.mkdtemp(prefix='rietveld_test') |
| 110 self.port = find_free_port(8080) | 110 self.port = find_free_port(10000) |
| 111 admin_port = find_free_port(self.port + 1) | 111 admin_port = find_free_port(self.port + 1) |
| 112 if verbose: | 112 if verbose: |
| 113 stdout = stderr = None | 113 stdout = stderr = None |
| 114 else: | 114 else: |
| 115 stdout = subprocess2.PIPE | 115 stdout = subprocess2.PIPE |
| 116 stderr = subprocess2.STDOUT | 116 stderr = subprocess2.STDOUT |
| 117 cmd = [ | 117 cmd = [ |
| 118 sys.executable, | 118 sys.executable, |
| 119 self.dev_app, | 119 self.dev_app, |
| 120 '.', | 120 '.', |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 instance.start_server(verbose=options.verbose) | 172 instance.start_server(verbose=options.verbose) |
| 173 print 'Local rietveld instance started on port %d' % instance.port | 173 print 'Local rietveld instance started on port %d' % instance.port |
| 174 while True: | 174 while True: |
| 175 time.sleep(0.1) | 175 time.sleep(0.1) |
| 176 finally: | 176 finally: |
| 177 instance.stop_server() | 177 instance.stop_server() |
| 178 | 178 |
| 179 | 179 |
| 180 if __name__ == '__main__': | 180 if __name__ == '__main__': |
| 181 main() | 181 main() |
| OLD | NEW |