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

Side by Side Diff: tools/test.py

Issue 6965008: Let test configuration disable variant flags. Used for preparser tests. (Closed)
Patch Set: Created 9 years, 7 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
« no previous file with comments | « test/preparser/testcfg.py ('k') | no next file » | 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 # 2 #
3 # Copyright 2008 the V8 project authors. All rights reserved. 3 # Copyright 2008 the V8 project authors. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 def GetCustomFlags(self, mode): 385 def GetCustomFlags(self, mode):
386 return None 386 return None
387 387
388 def Run(self): 388 def Run(self):
389 self.BeforeRun() 389 self.BeforeRun()
390 result = None 390 result = None
391 try: 391 try:
392 result = self.RunCommand(self.GetCommand()) 392 result = self.RunCommand(self.GetCommand())
393 except: 393 except:
394 self.terminate = True 394 self.terminate = True
395 raise BreakNowException("Used pressed CTRL+C or IO went wrong") 395 raise BreakNowException("User pressed CTRL+C or IO went wrong")
Rico 2011/05/09 08:22:45 thanks
396 finally: 396 finally:
397 self.AfterRun(result) 397 self.AfterRun(result)
398 return result 398 return result
399 399
400 def Cleanup(self): 400 def Cleanup(self):
401 return 401 return
402 402
403 403
404 class TestOutput(object): 404 class TestOutput(object):
405 405
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 return CommandOutput(exit_code, False, "", "") 559 return CommandOutput(exit_code, False, "", "")
560 560
561 561
562 def CarCdr(path): 562 def CarCdr(path):
563 if len(path) == 0: 563 if len(path) == 0:
564 return (None, [ ]) 564 return (None, [ ])
565 else: 565 else:
566 return (path[0], path[1:]) 566 return (path[0], path[1:])
567 567
568 568
569 # Use this to run several variants of the tests, e.g.:
570 # VARIANT_FLAGS = [[], ['--always_compact', '--noflush_code']]
571 VARIANT_FLAGS = [[],
572 ['--stress-opt', '--always-opt'],
573 ['--nocrankshaft']]
574
575
569 class TestConfiguration(object): 576 class TestConfiguration(object):
570 577
571 def __init__(self, context, root): 578 def __init__(self, context, root):
572 self.context = context 579 self.context = context
573 self.root = root 580 self.root = root
574 581
575 def Contains(self, path, file): 582 def Contains(self, path, file):
576 if len(path) > len(file): 583 if len(path) > len(file):
577 return False 584 return False
578 for i in xrange(len(path)): 585 for i in xrange(len(path)):
579 if not path[i].match(file[i]): 586 if not path[i].match(file[i]):
580 return False 587 return False
581 return True 588 return True
582 589
583 def GetTestStatus(self, sections, defs): 590 def GetTestStatus(self, sections, defs):
584 pass 591 pass
585 592
593 def VariantFlags(self):
594 return VARIANT_FLAGS
595
596
597
586 598
587 class TestSuite(object): 599 class TestSuite(object):
588 600
589 def __init__(self, name): 601 def __init__(self, name):
590 self.name = name 602 self.name = name
591 603
592 def GetName(self): 604 def GetName(self):
593 return self.name 605 return self.name
594 606
595 607
596 # Use this to run several variants of the tests, e.g.:
597 # VARIANT_FLAGS = [[], ['--always_compact', '--noflush_code']]
598 VARIANT_FLAGS = [[],
599 ['--stress-opt', '--always-opt'],
600 ['--nocrankshaft']]
601
602
603 class TestRepository(TestSuite): 608 class TestRepository(TestSuite):
604 609
605 def __init__(self, path): 610 def __init__(self, path):
606 normalized_path = abspath(path) 611 normalized_path = abspath(path)
607 super(TestRepository, self).__init__(basename(normalized_path)) 612 super(TestRepository, self).__init__(basename(normalized_path))
608 self.path = normalized_path 613 self.path = normalized_path
609 self.is_loaded = False 614 self.is_loaded = False
610 self.config = None 615 self.config = None
611 616
612 def GetConfiguration(self, context): 617 def GetConfiguration(self, context):
613 if self.is_loaded: 618 if self.is_loaded:
614 return self.config 619 return self.config
615 self.is_loaded = True 620 self.is_loaded = True
616 file = None 621 file = None
617 try: 622 try:
618 (file, pathname, description) = imp.find_module('testcfg', [ self.path ]) 623 (file, pathname, description) = imp.find_module('testcfg', [ self.path ])
619 module = imp.load_module('testcfg', file, pathname, description) 624 module = imp.load_module('testcfg', file, pathname, description)
620 self.config = module.GetConfiguration(context, self.path) 625 self.config = module.GetConfiguration(context, self.path)
621 finally: 626 finally:
622 if file: 627 if file:
623 file.close() 628 file.close()
624 return self.config 629 return self.config
625 630
626 def GetBuildRequirements(self, path, context): 631 def GetBuildRequirements(self, path, context):
627 return self.GetConfiguration(context).GetBuildRequirements() 632 return self.GetConfiguration(context).GetBuildRequirements()
628 633
629 def AddTestsToList(self, result, current_path, path, context, mode): 634 def AddTestsToList(self, result, current_path, path, context, mode):
630 for v in VARIANT_FLAGS: 635 for v in self.GetConfiguration(context).VariantFlags():
631 tests = self.GetConfiguration(context).ListTests(current_path, path, mode, v) 636 tests = self.GetConfiguration(context).ListTests(current_path, path, mode, v)
632 for t in tests: t.variant_flags = v 637 for t in tests: t.variant_flags = v
633 result += tests 638 result += tests
634 639
635
636 def GetTestStatus(self, context, sections, defs): 640 def GetTestStatus(self, context, sections, defs):
637 self.GetConfiguration(context).GetTestStatus(sections, defs) 641 self.GetConfiguration(context).GetTestStatus(sections, defs)
638 642
639 643
640 class LiteralTestSuite(TestSuite): 644 class LiteralTestSuite(TestSuite):
641 645
642 def __init__(self, tests): 646 def __init__(self, tests):
643 super(LiteralTestSuite, self).__init__('root') 647 super(LiteralTestSuite, self).__init__('root')
644 self.tests = tests 648 self.tests = tests
645 649
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 for entry in timed_tests[:20]: 1501 for entry in timed_tests[:20]:
1498 t = FormatTime(entry.duration) 1502 t = FormatTime(entry.duration)
1499 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) 1503 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel()))
1500 index += 1 1504 index += 1
1501 1505
1502 return result 1506 return result
1503 1507
1504 1508
1505 if __name__ == '__main__': 1509 if __name__ == '__main__':
1506 sys.exit(Main()) 1510 sys.exit(Main())
OLDNEW
« no previous file with comments | « test/preparser/testcfg.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698