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

Side by Side Diff: tools/test.py

Issue 42374: Patch by Erik Kay to allow specifying which shell to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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 | « no previous file | 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 stderr = fd_err, 472 stderr = fd_err,
473 ) 473 )
474 os.close(fd_out) 474 os.close(fd_out)
475 os.close(fd_err) 475 os.close(fd_err)
476 output = file(outname).read() 476 output = file(outname).read()
477 errors = file(errname).read() 477 errors = file(errname).read()
478 def CheckedUnlink(name): 478 def CheckedUnlink(name):
479 try: 479 try:
480 os.unlink(name) 480 os.unlink(name)
481 except OSError, e: 481 except OSError, e:
482 PrintError(str(e)) 482 PrintError("os.unlink() " + str(e))
483 CheckedUnlink(outname) 483 CheckedUnlink(outname)
484 CheckedUnlink(errname) 484 CheckedUnlink(errname)
485 return CommandOutput(exit_code, timed_out, output, errors) 485 return CommandOutput(exit_code, timed_out, output, errors)
486 486
487 487
488 def ExecuteNoCapture(args, context, timeout=None): 488 def ExecuteNoCapture(args, context, timeout=None):
489 (process, exit_code, timed_out) = RunProcess( 489 (process, exit_code, timed_out) = RunProcess(
490 context, 490 context,
491 timeout, 491 timeout,
492 args = args, 492 args = args,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 if not name or name.match(test_name): 583 if not name or name.match(test_name):
584 full_path = current_path + [test_name] 584 full_path = current_path + [test_name]
585 result += test.ListTests(full_path, path, context, mode) 585 result += test.ListTests(full_path, path, context, mode)
586 return result 586 return result
587 587
588 def GetTestStatus(self, context, sections, defs): 588 def GetTestStatus(self, context, sections, defs):
589 for test in self.tests: 589 for test in self.tests:
590 test.GetTestStatus(context, sections, defs) 590 test.GetTestStatus(context, sections, defs)
591 591
592 592
593 PREFIX = {'debug': '_g', 'release': ''} 593 SUFFIX = {'debug': '_g', 'release': ''}
594 594
595 595
596 class Context(object): 596 class Context(object):
597 597
598 def __init__(self, workspace, buildspace, verbose, vm, timeout, processor, sup press_dialogs): 598 def __init__(self, workspace, buildspace, verbose, vm, timeout, processor, sup press_dialogs):
599 self.workspace = workspace 599 self.workspace = workspace
600 self.buildspace = buildspace 600 self.buildspace = buildspace
601 self.verbose = verbose 601 self.verbose = verbose
602 self.vm_root = vm 602 self.vm_root = vm
603 self.timeout = timeout 603 self.timeout = timeout
604 self.processor = processor 604 self.processor = processor
605 self.suppress_dialogs = suppress_dialogs 605 self.suppress_dialogs = suppress_dialogs
606 606
607 def GetVm(self, mode): 607 def GetVm(self, mode):
608 name = self.vm_root + PREFIX[mode] 608 name = self.vm_root + SUFFIX[mode]
609 if utils.IsWindows(): 609 if utils.IsWindows() and not name.endswith('.exe'):
610 return name + '.exe' 610 name = name + '.exe'
611 else: 611 return name
612 return name
613 612
614 def RunTestCases(all_cases, progress, tasks): 613 def RunTestCases(all_cases, progress, tasks):
615 def DoSkip(case): 614 def DoSkip(case):
616 return SKIP in c.outcomes or SLOW in c.outcomes 615 return SKIP in c.outcomes or SLOW in c.outcomes
617 cases_to_run = [ c for c in all_cases if not DoSkip(c) ] 616 cases_to_run = [ c for c in all_cases if not DoSkip(c) ]
618 progress = PROGRESS_INDICATORS[progress](cases_to_run) 617 progress = PROGRESS_INDICATORS[progress](cases_to_run)
619 return progress.Run(tasks) 618 return progress.Run(tasks)
620 619
621 620
622 def BuildRequirements(context, requirements, mode, scons_flags): 621 def BuildRequirements(context, requirements, mode, scons_flags):
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 result.add_option("--warn-unused", help="Report unused rules", 1084 result.add_option("--warn-unused", help="Report unused rules",
1086 default=False, action="store_true") 1085 default=False, action="store_true")
1087 result.add_option("-j", help="The number of parallel tasks to run", 1086 result.add_option("-j", help="The number of parallel tasks to run",
1088 default=1, type="int") 1087 default=1, type="int")
1089 result.add_option("--time", help="Print timing information after running", 1088 result.add_option("--time", help="Print timing information after running",
1090 default=False, action="store_true") 1089 default=False, action="store_true")
1091 result.add_option("--suppress-dialogs", help="Suppress Windows dialogs for cra shing tests", 1090 result.add_option("--suppress-dialogs", help="Suppress Windows dialogs for cra shing tests",
1092 dest="suppress_dialogs", default=True, action="store_true") 1091 dest="suppress_dialogs", default=True, action="store_true")
1093 result.add_option("--no-suppress-dialogs", help="Display Windows dialogs for c rashing tests", 1092 result.add_option("--no-suppress-dialogs", help="Display Windows dialogs for c rashing tests",
1094 dest="suppress_dialogs", action="store_false") 1093 dest="suppress_dialogs", action="store_false")
1094 result.add_option("--shell", help="Path to V8 shell", default="shell");
1095 return result 1095 return result
1096 1096
1097 1097
1098 def ProcessOptions(options): 1098 def ProcessOptions(options):
1099 global VERBOSE 1099 global VERBOSE
1100 VERBOSE = options.verbose 1100 VERBOSE = options.verbose
1101 options.mode = options.mode.split(',') 1101 options.mode = options.mode.split(',')
1102 for mode in options.mode: 1102 for mode in options.mode:
1103 if not mode in ['debug', 'release']: 1103 if not mode in ['debug', 'release']:
1104 print "Unknown mode %s" % mode 1104 print "Unknown mode %s" % mode
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 for arg in args: 1215 for arg in args:
1216 path = SplitPath(arg) 1216 path = SplitPath(arg)
1217 paths.append(path) 1217 paths.append(path)
1218 1218
1219 # Check for --valgrind option. If enabled, we overwrite the special 1219 # Check for --valgrind option. If enabled, we overwrite the special
1220 # command flag with a command that uses the run-valgrind.py script. 1220 # command flag with a command that uses the run-valgrind.py script.
1221 if options.valgrind: 1221 if options.valgrind:
1222 run_valgrind = join(workspace, "tools", "run-valgrind.py") 1222 run_valgrind = join(workspace, "tools", "run-valgrind.py")
1223 options.special_command = "python -u " + run_valgrind + " @" 1223 options.special_command = "python -u " + run_valgrind + " @"
1224 1224
1225 # First build the required targets 1225 shell = abspath(options.shell)
1226 buildspace = abspath('.') 1226 buildspace = dirname(shell)
1227 context = Context(workspace, buildspace, VERBOSE, 1227 context = Context(workspace, buildspace, VERBOSE,
1228 join(buildspace, 'shell'), 1228 shell,
1229 options.timeout, 1229 options.timeout,
1230 GetSpecialCommandProcessor(options.special_command), 1230 GetSpecialCommandProcessor(options.special_command),
1231 options.suppress_dialogs) 1231 options.suppress_dialogs)
1232 if options.j != 1: 1232 # First build the required targets
1233 options.scons_flags += ['-j', str(options.j)]
1234 if not options.no_build: 1233 if not options.no_build:
1235 reqs = [ ] 1234 reqs = [ ]
1236 for path in paths: 1235 for path in paths:
1237 reqs += root.GetBuildRequirements(path, context) 1236 reqs += root.GetBuildRequirements(path, context)
1238 reqs = list(set(reqs)) 1237 reqs = list(set(reqs))
1239 if len(reqs) > 0: 1238 if len(reqs) > 0:
1239 if options.j != 1:
1240 options.scons_flags += ['-j', str(options.j)]
1240 if not BuildRequirements(context, reqs, options.mode, options.scons_flags) : 1241 if not BuildRequirements(context, reqs, options.mode, options.scons_flags) :
1241 return 1 1242 return 1
1242 1243
1243 # Get status for tests 1244 # Get status for tests
1244 sections = [ ] 1245 sections = [ ]
1245 defs = { } 1246 defs = { }
1246 root.GetTestStatus(context, sections, defs) 1247 root.GetTestStatus(context, sections, defs)
1247 config = Configuration(sections, defs) 1248 config = Configuration(sections, defs)
1248 1249
1249 # List the tests 1250 # List the tests
1250 all_cases = [ ] 1251 all_cases = [ ]
1251 all_unused = [ ] 1252 all_unused = [ ]
1252 unclassified_tests = [ ] 1253 unclassified_tests = [ ]
1253 globally_unused_rules = None 1254 globally_unused_rules = None
1254 for path in paths: 1255 for path in paths:
1255 for mode in options.mode: 1256 for mode in options.mode:
1257 if not exists(context.GetVm(mode)):
1258 print "Can't find shell executable: '%s'" % context.GetVm(mode)
1259 continue
1256 env = { 1260 env = {
1257 'mode': mode, 1261 'mode': mode,
1258 'system': utils.GuessOS(), 1262 'system': utils.GuessOS(),
1259 'arch': options.arch 1263 'arch': options.arch
1260 } 1264 }
1261 test_list = root.ListTests([], path, context, mode) 1265 test_list = root.ListTests([], path, context, mode)
1262 unclassified_tests += test_list 1266 unclassified_tests += test_list
1263 (cases, unused_rules, all_outcomes) = config.ClassifyTests(test_list, env) 1267 (cases, unused_rules, all_outcomes) = config.ClassifyTests(test_list, env)
1264 if globally_unused_rules is None: 1268 if globally_unused_rules is None:
1265 globally_unused_rules = set(unused_rules) 1269 globally_unused_rules = set(unused_rules)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 for entry in timed_tests[:20]: 1319 for entry in timed_tests[:20]:
1316 t = FormatTime(entry.duration) 1320 t = FormatTime(entry.duration)
1317 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel())) 1321 sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel()))
1318 index += 1 1322 index += 1
1319 1323
1320 return result 1324 return result
1321 1325
1322 1326
1323 if __name__ == '__main__': 1327 if __name__ == '__main__':
1324 sys.exit(Main()) 1328 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698