| 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 def windows_exit_handler(signal): | 92 # SIGINT is Ctrl-C. |
| 93 p.terminate() | 93 signal.signal(signal.SIGINT, signal_handler) |
| 94 sys.exit(0) | 94 # SIGTERM is sent by test.dart when a process times out. |
| 95 | 95 signal.signal(signal.SIGTERM, signal_handler) |
| 96 if os.name == 'nt' | 96 output, error = p.communicate() |
| 97 try: | 97 signal.signal(signal.SIGINT, signal.SIG_DFL) |
| 98 import win32api | 98 signal.signal(signal.SIGTERM, signal.SIG_DFL) |
| 99 win32api.SetConsoleCtrlHandler(windows_exit_handler, True) | |
| 100 except ImportError: | |
| 101 raise Exception("pywin32 not installed") | |
| 102 else: | |
| 103 # SIGINT is Ctrl-C. | |
| 104 signal.signal(signal.SIGINT, signal_handler) | |
| 105 # SIGTERM is sent by test.dart when a process times out. | |
| 106 signal.signal(signal.SIGTERM, signal_handler) | |
| 107 output, error = p.communicate() | |
| 108 signal.signal(signal.SIGINT, signal.SIG_DFL) | |
| 109 signal.signal(signal.SIGTERM, signal.SIG_DFL) | |
| 110 | 99 |
| 111 if p.returncode != 0: | 100 if p.returncode != 0: |
| 112 raise Exception('Failed to run command. return code=%s' % p.returncode) | 101 raise Exception('Failed to run command. return code=%s' % p.returncode) |
| 113 | 102 |
| 114 if out_expected_file: | 103 if out_expected_file: |
| 115 # Compare output to the given expectation file. | 104 # Compare output to the given expectation file. |
| 116 expectation = None | 105 expectation = None |
| 117 if is_png: | 106 if is_png: |
| 118 # DRT prints the image to STDOUT, but includes extra text that we trim: | 107 # DRT prints the image to STDOUT, but includes extra text that we trim: |
| 119 # - several header lines until a line saying 'Content-Length:' | 108 # - several header lines until a line saying 'Content-Length:' |
| (...skipping 29 matching lines...) Expand all Loading... |
| 149 print 'You can update expectations by running:\n' | 138 print 'You can update expectations by running:\n' |
| 150 print 'cp %s %s\n' % (out_file, out_expected_file) | 139 print 'cp %s %s\n' % (out_file, out_expected_file) |
| 151 print '#EOF' | 140 print '#EOF' |
| 152 | 141 |
| 153 if __name__ == '__main__': | 142 if __name__ == '__main__': |
| 154 try: | 143 try: |
| 155 sys.exit(main(sys.argv)) | 144 sys.exit(main(sys.argv)) |
| 156 except StandardError as e: | 145 except StandardError as e: |
| 157 print 'Fail: ' + str(e) | 146 print 'Fail: ' + str(e) |
| 158 sys.exit(1) | 147 sys.exit(1) |
| OLD | NEW |