| 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. |
| 11 """ | 11 """ |
| 12 | 12 |
| 13 import optparse | 13 import optparse |
| 14 import os | 14 import os |
| 15 import socket | 15 import socket |
| 16 import sys | 16 import sys |
| 17 import time | 17 import time |
| 18 | 18 |
| 19 sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..')) | |
| 20 import subprocess2 | 19 import subprocess2 |
| 21 | 20 |
| 22 | 21 |
| 23 class Failure(Exception): | 22 class Failure(Exception): |
| 24 pass | 23 pass |
| 25 | 24 |
| 26 | 25 |
| 27 def test_port(port): | 26 def test_port(port): |
| 28 s = socket.socket() | 27 s = socket.socket() |
| 29 try: | 28 try: |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 instance.start_server(verbose=options.verbose) | 143 instance.start_server(verbose=options.verbose) |
| 145 print 'Local rietveld instance started on port %d' % instance.port | 144 print 'Local rietveld instance started on port %d' % instance.port |
| 146 while True: | 145 while True: |
| 147 time.sleep(0.1) | 146 time.sleep(0.1) |
| 148 finally: | 147 finally: |
| 149 instance.stop_server() | 148 instance.stop_server() |
| 150 | 149 |
| 151 | 150 |
| 152 if __name__ == '__main__': | 151 if __name__ == '__main__': |
| 153 main() | 152 main() |
| OLD | NEW |