| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 """Docbuilder for extension docs.""" | 6 """Docbuilder for extension docs.""" |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import os.path | 9 import os.path |
| 10 import shutil | 10 import shutil |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 if (os.path.isfile(input_file)): | 53 if (os.path.isfile(input_file)): |
| 54 original = open(input_file, 'rb').read() | 54 original = open(input_file, 'rb').read() |
| 55 os.remove(input_file) | 55 os.remove(input_file) |
| 56 | 56 |
| 57 shutil.copy(_page_shell_html, input_file) | 57 shutil.copy(_page_shell_html, input_file) |
| 58 | 58 |
| 59 # Run test_shell and capture result | 59 # Run test_shell and capture result |
| 60 p = Popen([test_shell, "--layout-tests", generator_url], | 60 p = Popen([test_shell, "--layout-tests", generator_url], |
| 61 stdout=PIPE) | 61 stdout=PIPE) |
| 62 | 62 |
| 63 # the remaining output will be the content of the generated page. | 63 # The remaining output will be the content of the generated page. |
| 64 result = p.stdout.read() | 64 result = p.stdout.read() |
| 65 | 65 |
| 66 content_start = result.find(_expected_output_preamble) | 66 content_start = result.find(_expected_output_preamble) |
| 67 content_end = result.find(_expected_output_postamble) | 67 content_end = result.find(_expected_output_postamble) |
| 68 if (content_start < 0): | 68 if (content_start < 0): |
| 69 if (result.startswith("#TEST_TIMED_OUT")): | 69 if (result.startswith("#TEST_TIMED_OUT")): |
| 70 raise Exception("test_shell returned TEST_TIMED_OUT.\n" + | 70 raise Exception("test_shell returned TEST_TIMED_OUT.\n" + |
| 71 "Their was probably a problem with generating the " + | 71 "Their was probably a problem with generating the " + |
| 72 "page\n" + | 72 "page\n" + |
| 73 "Try copying template/page_shell.html to:\n" + | 73 "Try copying template/page_shell.html to:\n" + |
| 74 input_file + | 74 input_file + |
| 75 "\nAnd open it in chrome using the file: scheme.\n" + | 75 "\nAnd open it in chrome using the file: scheme.\n" + |
| 76 "Look from javascript errors via the inspector.") | 76 "Look from javascript errors via the inspector.") |
| 77 raise Exception("test_shell returned unexpected output: " + result) | 77 raise Exception("test_shell returned unexpected output: " + result) |
| 78 result = result[content_start:content_end + len(_expected_output_postamble)] +
"\n" | 78 postamble_length = len(_expected_output_postamble) |
| 79 result = result[content_start:content_end + postamble_length] + "\n" |
| 79 | 80 |
| 80 # remove the trailing #EOF that test shell appends to the output. | 81 # Remove the trailing #EOF that test shell appends to the output. |
| 81 result = result.replace('#EOF', '') | 82 result = result.replace('#EOF', '') |
| 82 | 83 |
| 83 # Remove page_shell | 84 # Remove page_shell |
| 84 os.remove(input_file) | 85 os.remove(input_file) |
| 85 | 86 |
| 86 # Remove CRs that are appearing from captured test_shell output. | 87 # Remove CRs that are appearing from captured test_shell output. |
| 87 result = result.replace('\r', '') | 88 result = result.replace('\r', '') |
| 88 | 89 |
| 89 # Write output | 90 # Write output |
| 90 open(input_file, 'wb').write(result) | 91 open(input_file, 'wb').write(result) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 # and the os.remove will fail with a "Permission denied". | 198 # and the os.remove will fail with a "Permission denied". |
| 198 time.sleep(1) | 199 time.sleep(1) |
| 199 debug_log = os.path.normpath(_build_dir + "/" + "debug.log") | 200 debug_log = os.path.normpath(_build_dir + "/" + "debug.log") |
| 200 if (os.path.isfile(debug_log)): | 201 if (os.path.isfile(debug_log)): |
| 201 os.remove(debug_log) | 202 os.remove(debug_log) |
| 202 | 203 |
| 203 return os.EX_OK | 204 return os.EX_OK |
| 204 | 205 |
| 205 if __name__ == '__main__': | 206 if __name__ == '__main__': |
| 206 sys.exit(main()) | 207 sys.exit(main()) |
| OLD | NEW |