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

Side by Side Diff: tests/selenium/main.py

Issue 235041: Modified output format to be accepted by Pulse. Updated DEPS to include newer... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 2 months 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
« no previous file with comments | « DEPS ('k') | tests/selenium/pdiff_test.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/python2.4 1 #!/usr/bin/python2.4
2 # Copyright 2009, Google Inc. 2 # Copyright 2009, Google Inc.
3 # All rights reserved. 3 # All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 self.sel_port, 377 self.sel_port,
378 browser + browser_path_with_space, 378 browser + browser_path_with_space,
379 server_url) 379 server_url)
380 380
381 new_session.start() 381 new_session.start()
382 new_session.set_timeout(self.sel_timeout) 382 new_session.set_timeout(self.sel_timeout)
383 383
384 return new_session 384 return new_session
385 385
386 386
387 def TestBrowser(session_builder, browser, test_list): 387 def TestBrowser(session_builder, browser, test_list, verbose):
388 """Runs Selenium tests for a specific browser. 388 """Runs Selenium tests for a specific browser.
389 389
390 Args: 390 Args:
391 session_builder: session_builder for creating new selenium sessions. 391 session_builder: session_builder for creating new selenium sessions.
392 browser: selenium browser name (eg. *iexplore, *firefox). 392 browser: selenium browser name (eg. *iexplore, *firefox).
393 test_list: list of tests. 393 test_list: list of tests.
394 394
395 Returns: 395 Returns:
396 summary_result: result of test runners. 396 summary_result: result of test runners.
397 """ 397 """
398 print "Testing %s..." % browser 398 print "Testing %s..." % browser
399 399
400 summary_result = test_runner.TestResult(test_runner.StringBuffer(), browser) 400 summary_result = test_runner.TestResult(test_runner.StringBuffer(), browser,
401 verbose)
401 402
402 # Fill up the selenium test queue. 403 # Fill up the selenium test queue.
403 test_queue = Queue.Queue() 404 test_queue = Queue.Queue()
404 for test in test_list: 405 for test in test_list:
405 test_queue.put(test) 406 test_queue.put(test)
406 407
407 408
408 pdiff_queue = None 409 pdiff_queue = None
409 if FLAGS.screenshots: 410 if FLAGS.screenshots:
410 # Need to do screen comparisons. 411 # Need to do screen comparisons.
411 # |pdiff_queue| is the queue of perceptual diff tests that need to be done. 412 # |pdiff_queue| is the queue of perceptual diff tests that need to be done.
412 # This queue is added to by individual slenium test runners. 413 # This queue is added to by individual slenium test runners.
413 # |pdiff_result_queue| is the result of the perceptual diff tests. 414 # |pdiff_result_queue| is the result of the perceptual diff tests.
414 pdiff_queue = Queue.Queue() 415 pdiff_queue = Queue.Queue()
415 pdiff_result_queue = Queue.Queue() 416 pdiff_result_queue = Queue.Queue()
416 pdiff_worker = test_runner.PDiffTestRunner(pdiff_queue, 417 pdiff_worker = test_runner.PDiffTestRunner(pdiff_queue,
417 pdiff_result_queue, 418 pdiff_result_queue,
418 browser) 419 browser, verbose)
419 pdiff_worker.start() 420 pdiff_worker.start()
420 421
421 # Start initial selenium test runner. 422 # Start initial selenium test runner.
422 worker = test_runner.SeleniumTestRunner(session_builder, browser, 423 worker = test_runner.SeleniumTestRunner(session_builder, browser,
423 test_queue, pdiff_queue) 424 test_queue, pdiff_queue,
425 verbose)
424 worker.start() 426 worker.start()
425 427
426 # Run through all selenium tests. 428 # Run through all selenium tests.
427 while not worker.IsCompletelyDone(): 429 while not worker.IsCompletelyDone():
428 if worker.IsTesting() and worker.IsPastDeadline(): 430 if worker.IsTesting() and worker.IsPastDeadline():
429 # Test has taken more than allotted. Abort and go to next test. 431 # Test has taken more than allotted. Abort and go to next test.
430 worker.AbortTest() 432 worker.AbortTest()
431 433
432 elif worker.DidFinishTest(): 434 elif worker.DidFinishTest():
433 # Do this so that a worker does not grab test off queue till we tell it. 435 # Do this so that a worker does not grab test off queue till we tell it.
434 result = worker.Continue() 436 result = worker.Continue()
435 result.printAll(sys.stdout) 437 result.printAll(sys.stdout)
436 summary_result.merge(result) 438 summary_result.merge(result)
439
440 # Sleep here for a brief time. This thread is polling the worker thread.
441 # We cannot wait for a message from the worker thread because the worker
442 # may hang on a bad test. We also do not want to sleep till the test's
443 # deadline because the test may finish before then.
444 time.sleep(.1)
437 445
438 if FLAGS.screenshots: 446 if FLAGS.screenshots:
439 # Finish screenshot comparisons. 447 # Finish screenshot comparisons.
440 pdiff_worker.EndTesting() 448 pdiff_worker.EndTesting()
441 while not pdiff_worker.IsCompletelyDone(): 449 while not pdiff_worker.IsCompletelyDone():
442 time.sleep(1) 450 time.sleep(1)
443 451
444 # Be careful here, make sure no one else is editing |pdiff_reult_queue|. 452 # Be careful here, make sure no one else is editing |pdiff_reult_queue|.
445 while not pdiff_result_queue.empty(): 453 while not pdiff_result_queue.empty():
446 result = pdiff_result_queue.get() 454 result = pdiff_result_queue.get()
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 sample = sample.strip() 507 sample = sample.strip()
500 if not sample or sample[0] == ";" or sample[0] == "#": 508 if not sample or sample[0] == ";" or sample[0] == "#":
501 continue 509 continue
502 510
503 arguments = sample.split() 511 arguments = sample.split()
504 test_type = arguments[0].lower() 512 test_type = arguments[0].lower()
505 test_path = arguments[1] 513 test_path = arguments[1]
506 options = arguments[2:] 514 options = arguments[2:]
507 515
508 # TODO: Add filter based on test_type 516 # TODO: Add filter based on test_type
517 test_skipped = False
509 if test_path.startswith("Test"): 518 if test_path.startswith("Test"):
510 name = test_path 519 name = test_path
511 else: 520 else:
512 # Need to make a name. 521 # Need to make a name.
513 name = ("Test" + prefix + re.sub("\W", "_", test_path) + 522 name = ("Test" + prefix + re.sub("\W", "_", test_path) +
514 test_type.capitalize()) 523 test_type.capitalize())
515 524 # Only test suffixes for generic tests. That is how it has always worked.
525 if test_suffixes and not MatchesSuffix(name, test_suffixes):
526 test_skipped = True
527
528 if test_prefix_filter and not name.startswith(test_prefix_filter):
529 test_skipped = True
530
516 # Only execute this test if the current browser is not in the list 531 # Only execute this test if the current browser is not in the list
517 # of skipped browsers. 532 # of skipped browsers.
518 test_skipped = False
519 screenshot_count = 0 533 screenshot_count = 0
520 for option in options: 534 for option in options:
521 if option.startswith("except"): 535 if option.startswith("except"):
522 skipped_platforms = selenium_utilities.GetArgument(option) 536 skipped_platforms = selenium_utilities.GetArgument(option)
523 if not skipped_platforms is None: 537 if not skipped_platforms is None:
524 skipped_platforms = skipped_platforms.split(",") 538 skipped_platforms = skipped_platforms.split(",")
525 if browser in skipped_platforms: 539 if browser in skipped_platforms:
526 test_skipped = True 540 test_skipped = True
527 elif option.startswith("screenshots"): 541 elif option.startswith("screenshots"):
528 screenshot_count += int(selenium_utilities.GetArgument(option)) 542 screenshot_count += int(selenium_utilities.GetArgument(option))
529 elif option.startswith("screenshot"): 543 elif option.startswith("screenshot"):
530 screenshot_count += 1 544 screenshot_count += 1
531 545
532 if (test_prefix_filter and not name.startswith(test_prefix_filter) or
533 test_suffixes and not MatchesSuffix(name, test_suffixes)):
534 test_skipped = True
535
536 if not test_skipped: 546 if not test_skipped:
537 # Add a test method with this name if it doesn't exist. 547 # Add a test method with this name if it doesn't exist.
538 if not (hasattr(module, name) and callable(getattr(module, name))): 548 if not (hasattr(module, name) and callable(getattr(module, name))):
539 setattr(module, name, module.GenericTest) 549 setattr(module, name, module.GenericTest)
540 550
541 new_test = module(name, browser, path_to_html, test_type, test_path, 551 new_test = module(name, browser, path_to_html, test_type, test_path,
542 options) 552 options)
543 553
544 if screenshot_count and FLAGS.screenshots: 554 if screenshot_count and FLAGS.screenshots:
545 pdiff_name = name + 'Screenshots' 555 pdiff_name = name + 'Screenshots'
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 http_server.http_port, 657 http_server.http_port,
648 FLAGS.browserpath) 658 FLAGS.browserpath)
649 659
650 all_tests_passed = True 660 all_tests_passed = True
651 # Test browsers. 661 # Test browsers.
652 for browser in FLAGS.browser: 662 for browser in FLAGS.browser:
653 if browser in set(selenium_constants.SELENIUM_BROWSER_SET): 663 if browser in set(selenium_constants.SELENIUM_BROWSER_SET):
654 test_list = GetTestsForBrowser(browser, FLAGS.testprefix, 664 test_list = GetTestsForBrowser(browser, FLAGS.testprefix,
655 FLAGS.testsuffixes) 665 FLAGS.testsuffixes)
656 666
657 result = TestBrowser(session_builder, browser, test_list) 667 result = TestBrowser(session_builder, browser, test_list, FLAGS.verbose)
658 668
659 if not result.wasSuccessful(): 669 if not result.wasSuccessful():
660 all_tests_passed = False 670 all_tests_passed = False
661 671
662 # Log non-succesful tests, for convenience. 672 # Log non-succesful tests, for convenience.
663 print "" 673 print ""
664 print "Failures for %s:" % browser 674 print "Failures for %s:" % browser
665 print "[Selenium tests]" 675 print "[Selenium tests]"
666 for entry in test_list: 676 for entry in test_list:
667 if type(entry) == tuple: 677 if type(entry) == tuple:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 735
726 # Setup the LD_LIBRARY_PATH on Linux. 736 # Setup the LD_LIBRARY_PATH on Linux.
727 if sys.platform[:5] == "linux": 737 if sys.platform[:5] == "linux":
728 if os.environ.get("LD_LIBRARY_PATH"): 738 if os.environ.get("LD_LIBRARY_PATH"):
729 os.environ["LD_LIBRARY_PATH"] = os.pathsep.join( 739 os.environ["LD_LIBRARY_PATH"] = os.pathsep.join(
730 [os.environ["LD_LIBRARY_PATH"], os.path.normpath(FLAGS.product_dir)]) 740 [os.environ["LD_LIBRARY_PATH"], os.path.normpath(FLAGS.product_dir)])
731 else: 741 else:
732 os.environ["LD_LIBRARY_PATH"] = os.path.normpath(FLAGS.product_dir) 742 os.environ["LD_LIBRARY_PATH"] = os.path.normpath(FLAGS.product_dir)
733 743
734 sys.exit(main(remaining_argv)) 744 sys.exit(main(remaining_argv))
OLDNEW
« no previous file with comments | « DEPS ('k') | tests/selenium/pdiff_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698