Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Side by Side Diff: app_test.py

Issue 11535002: chromium-build app now renders console from stored rows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-build
Patch Set: Minor fixes found during further development Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« app.py ('K') | « app.py ('k') | handler.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 import datetime 6 import datetime
7 import os 7 import os
8 import unittest 8 import unittest
9 import ast
cmp 2012/12/27 01:19:22 move before line 6
agable 2012/12/28 23:56:08 Done.
9 10
10 import app 11 import app
11 12
12 13
13 TEST_DIR = os.path.join(os.path.dirname(__file__), 'tests') 14 TEST_DIR = os.path.join(os.path.dirname(__file__), 'tests')
14 15
15 16
16 class GaeTestCase(unittest.TestCase): 17 class GaeTestCase(unittest.TestCase):
17 def setUp(self, *args, **kwargs): 18 def setUp(self, *args, **kwargs):
18 self.clear_datastore() 19 self.clear_datastore()
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 self.save_page(localpath='chromium/sheriff_perf.js', 198 self.save_page(localpath='chromium/sheriff_perf.js',
198 content='document.write(\'sheriff5\')') 199 content='document.write(\'sheriff5\')')
199 self.save_page(localpath='chromium/sheriff_cros_mtv.js', 200 self.save_page(localpath='chromium/sheriff_cros_mtv.js',
200 content='document.write(\'sheriff6, sheriff7\')') 201 content='document.write(\'sheriff6, sheriff7\')')
201 self.save_page(localpath='chromium/sheriff_cros_nonmtv.js', 202 self.save_page(localpath='chromium/sheriff_cros_nonmtv.js',
202 content='document.write(\'sheriff8\')') 203 content='document.write(\'sheriff8\')')
203 input_console = self._load_content(test_dir, 'console-input.html') 204 input_console = self._load_content(test_dir, 'console-input.html')
204 expected_console = self._load_content(test_dir, 'console-expected.html') 205 expected_console = self._load_content(test_dir, 'console-expected.html')
205 page_data = {'content': input_console} 206 page_data = {'content': input_console}
206 actual_console = app.console_handler( 207 actual_console = app.console_handler(
207 _unquoted_localpath='chromium/console', 208 unquoted_localpath='chromium/console',
208 remoteurl='http://build.chromium.org/p/chromium/console', 209 remoteurl='http://build.chromium.org/p/chromium/console',
209 page_data=page_data) 210 page_data=page_data)
210 # Uncomment if deeper inspection is needed of the returned console. 211 # Uncomment if deeper inspection is needed of the returned console.
211 # with open(os.path.join(test_dir, 'console-expected.html'), 'w') as fh: 212 # with open(os.path.join(test_dir, 'console-expected.html'), 'w') as fh:
212 # fh.write(actual_console['content']) 213 # fh.write(actual_console['content'])
213 self.assertEquals(expected_console, actual_console['content'], 214 self.assertEquals(expected_console, actual_console['content'],
214 'Unexpected console output found') 215 'Unexpected console output found')
215 216
216 def test_console_handler_utf8(self): 217 def test_console_handler_utf8(self):
217 test_dir = os.path.join(TEST_DIR, 'test_console_handler_utf8') 218 test_dir = os.path.join(TEST_DIR, 'test_console_handler_utf8')
218 self.save_page(localpath='chromium/sheriff.js', 219 self.save_page(localpath='chromium/sheriff.js',
219 content='document.write(\'sheriff1\')') 220 content='document.write(\'sheriff1\')')
220 self.save_page(localpath='chromium/sheriff_webkit.js', 221 self.save_page(localpath='chromium/sheriff_webkit.js',
221 content='document.write(\'sheriff2\')') 222 content='document.write(\'sheriff2\')')
222 self.save_page(localpath='chromium/sheriff_memory.js', 223 self.save_page(localpath='chromium/sheriff_memory.js',
223 content='document.write(\'sheriff3\')') 224 content='document.write(\'sheriff3\')')
224 self.save_page(localpath='chromium/sheriff_nacl.js', 225 self.save_page(localpath='chromium/sheriff_nacl.js',
225 content='document.write(\'sheriff4\')') 226 content='document.write(\'sheriff4\')')
226 self.save_page(localpath='chromium/sheriff_perf.js', 227 self.save_page(localpath='chromium/sheriff_perf.js',
227 content='document.write(\'sheriff5\')') 228 content='document.write(\'sheriff5\')')
228 self.save_page(localpath='chromium/sheriff_cros_mtv.js', 229 self.save_page(localpath='chromium/sheriff_cros_mtv.js',
229 content='document.write(\'sheriff6, sheriff7\')') 230 content='document.write(\'sheriff6, sheriff7\')')
230 self.save_page(localpath='chromium/sheriff_cros_nonmtv.js', 231 self.save_page(localpath='chromium/sheriff_cros_nonmtv.js',
231 content='document.write(\'sheriff8\')') 232 content='document.write(\'sheriff8\')')
232 input_console = self._load_content(test_dir, 'console-input.html') 233 input_console = self._load_content(test_dir, 'console-input.html')
233 expected_console = self._load_content(test_dir, 'console-expected.html') 234 expected_console = self._load_content(test_dir, 'console-expected.html')
234 page_data = {'content': input_console} 235 page_data = {'content': input_console}
235 actual_console = app.console_handler( 236 actual_console = app.console_handler(
236 _unquoted_localpath='chromium/console', 237 unquoted_localpath='chromium/console',
237 remoteurl='http://build.chromium.org/p/chromium/console', 238 remoteurl='http://build.chromium.org/p/chromium/console',
238 page_data=page_data) 239 page_data=page_data)
239 # Uncomment if deeper inspection is needed of the returned console. 240 # Uncomment if deeper inspection is needed of the returned console.
240 # with open(os.path.join(test_dir, 'console-expected.html'), 'w') as fh: 241 # with open(os.path.join(test_dir, 'console-expected.html'), 'w') as fh:
241 # fh.write(actual_console['content']) 242 # fh.write(actual_console['content'])
242 self.assertEquals(expected_console, actual_console['content'], 243 self.assertEquals(expected_console, actual_console['content'],
243 'Unexpected console output found') 244 'Unexpected console output found')
244 245
245 def test_parse_master(self): 246 def test_parse_master(self):
246 test_dir = os.path.join(TEST_DIR, 'test_parse_master') 247 test_dir = os.path.join(TEST_DIR, 'test_parse_master')
247 expected_rev = self._load_content(test_dir, 'expected-rev.html').strip() 248 expected_rev = self._load_content(test_dir, 'expected-rev.html').strip()
248 expected_name = self._load_content(test_dir, 'expected-name.html').strip() 249 expected_name = self._load_content(test_dir, 'expected-name.html').strip()
249 expected_status = self._load_content(test_dir, 250 expected_status = self._load_content(test_dir,
250 'expected-status.html').strip() 251 'expected-status.html').strip()
251 expected_comment = self._load_content(test_dir, 252 expected_comment = self._load_content(test_dir,
252 'expected-comment.html').strip() 253 'expected-comment.html').strip()
253 expected_details = self._load_content(test_dir, 254 expected_details = self._load_content(test_dir,
254 'expected-details.html').strip() 255 'expected-details.html').strip()
255 expected_summary = self._load_content(test_dir, 256 expected_summary = self._load_content(test_dir,
256 'expected-summary.html').strip() 257 'expected-summary.html').strip()
257 print(expected_summary)
258 print("\n\n\n\n")
259 input_console = self._load_content(test_dir, 'console-input-handled.html') 258 input_console = self._load_content(test_dir, 'console-input-handled.html')
260 page_data = {'content': input_console} 259 page_data = {'content': input_console}
261 test_localpath = 'chromium/console' 260 test_localpath = 'chromium/console'
262 # Parse master returns its input, so we throw that away and access 261 # Parse master returns its input, so we throw that away and access
263 # the stored rows directly. 262 # the stored rows directly.
264 app.parse_master( 263 app.parse_master(
265 localpath=test_localpath, 264 localpath=test_localpath,
266 remoteurl='http://build.chromium.org/p/chromium/console', 265 remoteurl='http://build.chromium.org/p/chromium/console',
267 page_data=page_data) 266 page_data=page_data)
268 test_revision = '121192' 267 test_revision = '121192'
269 actual_row = app.Row.get_by_key_name(test_revision + ' ' + test_localpath) 268 actual_row = app.get_and_cache_rowdata(test_localpath + '/' + test_revision)
270 actual_row = app.db.to_dict(actual_row) 269 actual_summary = app.get_and_cache_pagedata(test_localpath + '/summary')
271 actual_summary = app.Page.get_by_key_name(test_localpath + '/summary') 270 self.assertEquals(expected_rev, actual_row['rev'],
272 actual_summary = app.db.to_dict(actual_summary)
273 print(actual_summary['content'])
274 self.assertEquals(expected_rev, actual_row['revision'],
275 'Unexpected revision number found') 271 'Unexpected revision number found')
276 self.assertEquals(expected_name, actual_row['name'], 272 self.assertEquals(expected_name, actual_row['name'],
277 'Unexpected revision author found') 273 'Unexpected revision author found')
278 self.assertEquals(expected_status, actual_row['status'], 274 self.assertEquals(expected_status, actual_row['status'],
279 'Unexpected build status found') 275 'Unexpected build status found')
280 self.assertEquals(expected_comment, actual_row['comment'], 276 self.assertEquals(expected_comment, actual_row['comment'],
281 'Unexpected commit message found') 277 'Unexpected commit message found')
282 self.assertEquals(expected_details, actual_row['details'], 278 self.assertEquals(expected_details, actual_row['details'],
283 'Unexpected build details found') 279 'Unexpected build details found')
284 self.assertEquals(expected_summary, actual_summary['content'], 280 self.assertEquals(expected_summary, actual_summary['content'],
285 'Unexpected build summary found') 281 'Unexpected build summary found')
286 282
287 283
284 # def test_generate_handled_stuff(self):
285 # # Read in all the necessary input files.
286 # test_dir = os.path.join(TEST_DIR, 'test_console_merger')
287 # test_masters = ['linux', 'mac', 'win', 'memory']
288 # filenames = []
289 # #filenames = ['surroundings_input.html']
290 # for master in test_masters:
291 # localpath = 'chromium.%s/console' % master
292 # filename = '%s_console_input.html' % master
293 # fileobj = self._load_content(test_dir, filename)
294 # self.save_page(localpath, fileobj)
295 # page_data = app.get_and_cache_pagedata(localpath)
296 # remoteurl = 'http://build.chromium.org/p/%s' % localpath
297 # handled = app.console_handler(localpath, remoteurl, page_data)
298 # out = open('%s_console_handled.html' % master, 'w')
299 # out.write(handled['content'])
cmp 2012/12/27 01:19:22 I suppose you used this to generate extra data tha
agable 2012/12/28 23:56:08 I've decided to remove them. This was helpful for
300
301
288 def test_console_merger(self): 302 def test_console_merger(self):
303 # Read in all the necessary input files.
289 test_dir = os.path.join(TEST_DIR, 'test_console_merger') 304 test_dir = os.path.join(TEST_DIR, 'test_console_merger')
290 filedata = {} 305 test_masters = ['linux', 'mac', 'win', 'memory']
291 for filename in [ 306 filenames = ['latest_rev.txt', 'surroundings_input.html']
292 'chromium_chrome_console_input.html', 307 for master in test_masters:
293 'chromium_chromiumos_console_input.html', 308 filenames += ['%s_categories_input.html' % master,
294 'chromium_main_console_input.html', 309 '%s_summary_input.html' % master,
295 'chromium_memory_console_input.html', 310 '%s_row_input.txt' % master]
296 'chromium_merged_console.html', 311 filenames.append('merged_console_output.html')
297 ]: 312 files = {}
298 filedata[filename] = self._load_content(test_dir, filename) 313 for filename in filenames:
299 self.save_page(localpath='chromium.chrome/console', 314 files[filename] = self._load_content(test_dir, filename)
300 content=filedata['chromium_chrome_console_input.html']) 315
301 self.save_page(localpath='chromium.chromiumos/console', 316 # Save the input files as the corresponding pages and rows.
302 content=filedata['chromium_chromiumos_console_input.html']) 317 test_rev = files['latest_rev.txt'].strip()
303 self.save_page(localpath='chromium.main/console', 318 app.memcache.set(key='latest_rev', value=test_rev)
304 content=filedata['chromium_main_console_input.html']) 319 self.save_page(localpath='surroundings',
305 self.save_page(localpath='chromium.memory/console', 320 content=files['surroundings_input.html'])
306 content=filedata['chromium_memory_console_input.html']) 321 for master in test_masters:
307 page_data = {'content': filedata['chromium_merged_console.html']} 322 self.save_page('chromium.%s/console/categories' % master,
323 files['%s_categories_input.html' % master])
324 self.save_page('chromium.%s/console/summary' % master,
325 files['%s_summary_input.html' % master])
326 app.save_row(ast.literal_eval(files['%s_row_input.txt' % master]),
327 'chromium.%s/console/%s' % (master, test_rev),
328 datetime.datetime.now())
329
330 # Get the expected and real output, compare.
331 self.save_page('merged_output', files['merged_console_output.html'])
308 app.console_merger( 332 app.console_merger(
309 'chromium.main/console', 333 'chromium/console', '', {},
310 'http://build.chromium.org/p/chromium/console',
311 page_data=page_data,
312 masters_to_merge=[ 334 masters_to_merge=[
313 'chromium.main', 335 'chromium.linux',
314 'chromium.chromiumos', 336 'chromium.mac',
315 'chromium.chrome', 337 'chromium.win',
316 'chromium.memory', 338 'chromium.memory',
317 ]) 339 ],
340 num_rows_to_merge=1)
318 actual_mergedconsole = app.get_and_cache_pagedata('chromium/console') 341 actual_mergedconsole = app.get_and_cache_pagedata('chromium/console')
319 # Uncomment if deeper inspection is needed of the returned console. 342 # Uncomment if deeper inspection is needed of the returned console.
320 # import logging 343 # import logging
321 # logging.debug('foo') 344 # logging.debug('foo')
322 # with open(os.path.join(test_dir, 'chromium_merged_console.html'), 345 # with open(os.path.join(test_dir, 'merged_console_output.html'),
323 # 'w') as fh: 346 # 'w') as fh:
324 # fh.write(actual_mergedconsole['content']) 347 # fh.write(actual_mergedconsole['content'])
325 # import code 348 # import code
326 # code.interact(local=locals()) 349 # code.interact(local=locals())
327 self.assertEquals(filedata['chromium_merged_console.html'], 350 self.assertEquals(files['merged_console_output.html'],
328 actual_mergedconsole['content'], 351 actual_mergedconsole['content'],
329 'Unexpected console output found') 352 'Unexpected console output found')
330 353
331 def test_console_merger_utf8(self): 354 def test_console_merger_splitrevs(self):
cmp 2012/12/27 01:19:22 Not sure if you mean to remove test_console_merger
332 test_dir = os.path.join(TEST_DIR, 'test_console_merger_utf8') 355 # Read in all the necessary input files.
333 filedata = {} 356 test_dir = os.path.join(TEST_DIR, 'test_console_merger_splitrevs')
334 for filename in [ 357 test_masters = ['linux', 'mac']
335 'chromium_chrome_console_input.html', 358 filenames = ['latest_rev.txt', 'surroundings_input.html']
336 'chromium_chromiumos_console_input.html', 359 for master in test_masters:
337 'chromium_main_console_input.html', 360 filenames += ['%s_categories_input.html' % master,
338 'chromium_memory_console_input.html', 361 '%s_summary_input.html' % master,
339 'chromium_merged_console.html', 362 '%s_row_input.txt' % master]
340 ]: 363 filenames.append('merged_console_output.html')
341 filedata[filename] = self._load_content(test_dir, filename) 364 files = {}
342 self.save_page(localpath='chromium.chrome/console', 365 for filename in filenames:
343 content=filedata['chromium_chrome_console_input.html']) 366 files[filename] = self._load_content(test_dir, filename)
344 self.save_page(localpath='chromium.chromiumos/console', 367
345 content=filedata['chromium_chromiumos_console_input.html']) 368 # Save the input files as the corresponding pages and rows.
346 self.save_page(localpath='chromium.main/console', 369 test_rev = files['latest_rev.txt'].strip()
347 content=filedata['chromium_main_console_input.html']) 370 app.memcache.set(key='latest_rev', value=test_rev)
348 self.save_page(localpath='chromium.memory/console', 371 self.save_page(localpath='surroundings',
349 content=filedata['chromium_memory_console_input.html']) 372 content=files['surroundings_input.html'])
350 page_data = {'content': filedata['chromium_merged_console.html']} 373 for master in test_masters:
374 self.save_page('chromium.%s/console/categories' % master,
375 files['%s_categories_input.html' % master])
376 self.save_page('chromium.%s/console/summary' % master,
377 files['%s_summary_input.html' % master])
378 app.save_row(ast.literal_eval(files['%s_row_input.txt' % master]),
379 'chromium.%s/console/%s' % (master, test_rev),
380 datetime.datetime.now())
381
382 # Get the expected and real output, compare.
383 self.save_page('merged_output', files['merged_console_output.html'])
351 app.console_merger( 384 app.console_merger(
352 'chromium.main/console', 385 'chromium/console', '', {},
353 'http://build.chromium.org/p/chromium/console',
354 page_data=page_data,
355 masters_to_merge=[ 386 masters_to_merge=[
356 'chromium.main', 387 'chromium.linux',
357 'chromium.chromiumos', 388 'chromium.mac',
358 'chromium.chrome', 389 ],
359 'chromium.memory', 390 num_rows_to_merge=1)
360 ])
361 actual_mergedconsole = app.get_and_cache_pagedata('chromium/console') 391 actual_mergedconsole = app.get_and_cache_pagedata('chromium/console')
362 # Uncomment if deeper inspection is needed of the returned console. 392 # Uncomment if deeper inspection is needed of the returned console.
363 # import logging 393 # import logging
364 # logging.debug('foo') 394 # logging.debug('foo')
365 # merged_path = os.path.join(test_dir, 'chromium_merged_console.html') 395 # with open(os.path.join(test_dir, 'merged_console_output.html'),
366 # with open(merged_path, 'w') as fh:
367 # fh.write(actual_mergedconsole['content'])
368 # import code
369 # code.interact(local=locals())
370 self.assertEquals(filedata['chromium_merged_console.html'],
371 actual_mergedconsole['content'],
372 'Unexpected console output found')
373
374 def test_console_merger_splitrevs(self):
375 test_dir = os.path.join(TEST_DIR, 'test_console_merger_splitrevs')
376 filedata = {}
377 for filename in [
378 'chromium_chrome_console.html',
379 'chromium_chromiumos_console.html',
380 'chromium_console.html',
381 'chromium_memory_console.html',
382 'chromium_merged_console.html',
383 ]:
384 filedata[filename] = self._load_content(test_dir, filename)
385 self.save_page(localpath='chromium.chrome/console',
386 content=filedata['chromium_chrome_console.html'])
387 self.save_page(localpath='chromium.chromiumos/console',
388 content=filedata['chromium_chromiumos_console.html'])
389 self.save_page(localpath='chromium.main/console',
390 content=filedata['chromium_console.html'])
391 self.save_page(localpath='chromium.memory/console',
392 content=filedata['chromium_memory_console.html'])
393 page_data = {'content': filedata['chromium_merged_console.html']}
394 app.console_merger(
395 'chromium.main/console',
396 'http://build.chromium.org/p/chromium/console',
397 page_data=page_data,
398 masters_to_merge=[
399 'chromium.main',
400 'chromium.chromiumos',
401 'chromium.chrome',
402 'chromium.memory',
403 ])
404 actual_mergedconsole = app.get_and_cache_pagedata('chromium/console')
405 # Uncomment if deeper inspection is needed of the returned console.
406 # import logging
407 # logging.debug('foo')
408 # with open(os.path.join(test_dir, 'chromium_merged_console.html'),
409 # 'w') as fh: 396 # 'w') as fh:
410 # fh.write(actual_mergedconsole['content']) 397 # fh.write(actual_mergedconsole['content'])
411 # import code 398 # import code
412 # code.interact(local=locals()) 399 # code.interact(local=locals())
413 self.assertEquals(filedata['chromium_merged_console.html'], 400 self.assertEquals(files['merged_console_output.html'],
414 actual_mergedconsole['content'], 401 actual_mergedconsole['content'],
415 'Unexpected console output found') 402 'Unexpected console output found')
416 403
417 404
418 class FetchTestCase(GaeTestCase): 405 class FetchTestCase(GaeTestCase):
419 class FakeResponse(object): 406 class FakeResponse(object):
420 status_code = 200 407 status_code = 200
421 content = None 408 content = None
422 409
423 def test_fetch_direct(self): 410 def test_fetch_direct(self):
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 page = app.get_and_cache_pagedata('chromium/console') 447 page = app.get_and_cache_pagedata('chromium/console')
461 # Uncomment if deeper inspection is needed of the returned console. 448 # Uncomment if deeper inspection is needed of the returned console.
462 # with open(os.path.join(test_dir, 'expected.html'), 'w') as fh: 449 # with open(os.path.join(test_dir, 'expected.html'), 'w') as fh:
463 # fh.write(page['content']) 450 # fh.write(page['content'])
464 self.assertEquals('interface', page['body_class']) 451 self.assertEquals('interface', page['body_class'])
465 self.assertEquals(expected_content, page['content']) 452 self.assertEquals(expected_content, page['content'])
466 self.assertEquals( 453 self.assertEquals(
467 'http://build.chromium.org/p/chromium/console/../', 454 'http://build.chromium.org/p/chromium/console/../',
468 page['offsite_base']) 455 page['offsite_base'])
469 self.assertEquals('BuildBot: Chromium', page['title']) 456 self.assertEquals('BuildBot: Chromium', page['title'])
OLDNEW
« app.py ('K') | « app.py ('k') | handler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698