OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 # Run build_server so that files needed by tests are copied to the local | 6 # Run build_server so that files needed by tests are copied to the local |
7 # third_party directory. | 7 # third_party directory. |
8 import build_server | 8 import build_server |
9 build_server.main() | 9 build_server.main() |
10 | 10 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 def check_result(response): | 180 def check_result(response): |
181 self.assertEqual(200, response.status, | 181 self.assertEqual(200, response.status, |
182 'Got %s when rendering %s' % (response.status, path)) | 182 'Got %s when rendering %s' % (response.status, path)) |
183 | 183 |
184 # This is reaaaaally rough since usually these will be tiny templates | 184 # This is reaaaaally rough since usually these will be tiny templates |
185 # that render large files. At least it'll catch zero-length responses. | 185 # that render large files. At least it'll catch zero-length responses. |
186 self.assertTrue(len(response.content) >= len(content), | 186 self.assertTrue(len(response.content) >= len(content), |
187 'Rendered content length was %s vs template content length %s ' | 187 'Rendered content length was %s vs template content length %s ' |
188 'when rendering %s' % (len(response.content), len(content), path)) | 188 'when rendering %s' % (len(response.content), len(content), path)) |
189 | 189 |
190 check_result(Handler(Request.ForTest(path)).Get()) | 190 # TODO(kalman): Hack to avoid failing redirects like extensions/index |
| 191 # to extensions. Better fix would be to parse or whitelist the |
| 192 # redirects.json files as part of this test. |
| 193 if not path.endswith('/index'): |
| 194 check_result(Handler(Request.ForTest(path)).Get()) |
191 | 195 |
192 if path.startswith(('apps/', 'extensions/')): | 196 if path.startswith(('apps/', 'extensions/')): |
193 # Make sure that adding the .html will temporarily redirect to | 197 # Make sure that adding the .html will temporarily redirect to |
194 # the path without the .html for APIs and articles. | 198 # the path without the .html for APIs and articles. |
195 if '/examples/' not in path: | 199 if '/examples/' not in path: |
196 redirect_response = Handler(Request.ForTest(path + '.html')).Get() | 200 redirect_response = Handler(Request.ForTest(path + '.html')).Get() |
197 self.assertEqual( | 201 self.assertEqual( |
198 ('/' + path, False), redirect_response.GetRedirect(), | 202 ('/' + path, False), redirect_response.GetRedirect(), |
199 '%s.html did not (temporarily) redirect to %s (status %s)' % | 203 '%s.html did not (temporarily) redirect to %s (status %s)' % |
200 (path, path, redirect_response.status)) | 204 (path, path, redirect_response.status)) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 parser.add_option('-v', '--verbose', action='store_true', default=False, | 286 parser.add_option('-v', '--verbose', action='store_true', default=False, |
283 help='Show verbose output like currently broken links') | 287 help='Show verbose output like currently broken links') |
284 (opts, args) = parser.parse_args() | 288 (opts, args) = parser.parse_args() |
285 if not opts.all: | 289 if not opts.all: |
286 _EXPLICIT_TEST_FILES = args | 290 _EXPLICIT_TEST_FILES = args |
287 _REBASE = opts.rebase | 291 _REBASE = opts.rebase |
288 _VERBOSE = opts.verbose | 292 _VERBOSE = opts.verbose |
289 # Kill sys.argv because we have our own flags. | 293 # Kill sys.argv because we have our own flags. |
290 sys.argv = [sys.argv[0]] | 294 sys.argv = [sys.argv[0]] |
291 unittest.main() | 295 unittest.main() |
OLD | NEW |