Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 # | 4 # |
| 5 # For now we have to use this trampoline to turn --dart-flags command line | 5 # For now we have to use this trampoline to turn --dart-flags command line |
| 6 # switch into env variable DART_FLAGS. Eventually, DumpRenderTree should | 6 # switch into env variable DART_FLAGS. Eventually, DumpRenderTree should |
| 7 # support --dart-flags and this hack may go away. | 7 # support --dart-flags and this hack may go away. |
| 8 # | 8 # |
| 9 # Expected invocation: python drt-trampoline.py <path to DRT> <DRT command line> | 9 # Expected invocation: python drt-trampoline.py <path to DRT> <DRT command line> |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 else: | 82 else: |
| 83 cmd.append(test_file) | 83 cmd.append(test_file) |
| 84 | 84 |
| 85 stdout = subprocess.PIPE if out_expected_file else None | 85 stdout = subprocess.PIPE if out_expected_file else None |
| 86 p = subprocess.Popen(cmd, env=env, stdout=stdout) | 86 p = subprocess.Popen(cmd, env=env, stdout=stdout) |
| 87 | 87 |
| 88 def signal_handler(signal, frame): | 88 def signal_handler(signal, frame): |
| 89 p.terminate() | 89 p.terminate() |
| 90 sys.exit(0) | 90 sys.exit(0) |
| 91 | 91 |
| 92 # SIGINT is Ctrl-C. | 92 def windows_exit_handler(signal): |
| 93 signal.signal(signal.SIGINT, signal_handler) | 93 p.terminate() |
| 94 # SIGTERM is sent by test.dart when a process times out. | 94 sys.exit(0) |
| 95 signal.signal(signal.SIGTERM, signal_handler) | 95 |
| 96 output, error = p.communicate() | 96 if os.name == 'nt' |
| 97 signal.signal(signal.SIGINT, signal.SIG_DFL) | 97 try: |
| 98 signal.signal(signal.SIGTERM, signal.SIG_DFL) | 98 import win32api |
| 99 win32api.SetConsoleCtrlHandler(windows_exit_handler, True) | |
| 100 except ImportError: | |
| 101 version = ".".join(map(str, sys.version_info[:2])) | |
|
kustermann
2012/12/13 14:10:02
I think "str" is not defined here
kustermann
2012/12/13 14:11:06
Sorry, I forgot that it's in the builtins.
| |
| 102 raise Exception("pywin32 not installed for Python " + version) | |
| 103 else: | |
| 104 # SIGINT is Ctrl-C. | |
| 105 signal.signal(signal.SIGINT, signal_handler) | |
| 106 # SIGTERM is sent by test.dart when a process times out. | |
| 107 signal.signal(signal.SIGTERM, signal_handler) | |
| 108 output, error = p.communicate() | |
| 109 signal.signal(signal.SIGINT, signal.SIG_DFL) | |
| 110 signal.signal(signal.SIGTERM, signal.SIG_DFL) | |
| 99 | 111 |
| 100 if p.returncode != 0: | 112 if p.returncode != 0: |
| 101 raise Exception('Failed to run command. return code=%s' % p.returncode) | 113 raise Exception('Failed to run command. return code=%s' % p.returncode) |
| 102 | 114 |
| 103 if out_expected_file: | 115 if out_expected_file: |
| 104 # Compare output to the given expectation file. | 116 # Compare output to the given expectation file. |
| 105 expectation = None | 117 expectation = None |
| 106 if is_png: | 118 if is_png: |
| 107 # DRT prints the image to STDOUT, but includes extra text that we trim: | 119 # DRT prints the image to STDOUT, but includes extra text that we trim: |
| 108 # - several header lines until a line saying 'Content-Length:' | 120 # - several header lines until a line saying 'Content-Length:' |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 138 print 'You can update expectations by running:\n' | 150 print 'You can update expectations by running:\n' |
| 139 print 'cp %s %s\n' % (out_file, out_expected_file) | 151 print 'cp %s %s\n' % (out_file, out_expected_file) |
| 140 print '#EOF' | 152 print '#EOF' |
| 141 | 153 |
| 142 if __name__ == '__main__': | 154 if __name__ == '__main__': |
| 143 try: | 155 try: |
| 144 sys.exit(main(sys.argv)) | 156 sys.exit(main(sys.argv)) |
| 145 except StandardError as e: | 157 except StandardError as e: |
| 146 print 'Fail: ' + str(e) | 158 print 'Fail: ' + str(e) |
| 147 sys.exit(1) | 159 sys.exit(1) |
| OLD | NEW |