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

Side by Side Diff: tools/testrunner/local/commands.py

Issue 106443002: 'make quickcheck': Assorted improvements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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
« no previous file with comments | « tools/run-tests.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 # Copyright 2012 the V8 project authors. All rights reserved. 1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 try: 57 try:
58 import ctypes 58 import ctypes
59 prev_error_mode = \ 59 prev_error_mode = \
60 ctypes.windll.kernel32.SetErrorMode(mode) #@UndefinedVariable 60 ctypes.windll.kernel32.SetErrorMode(mode) #@UndefinedVariable
61 except ImportError: 61 except ImportError:
62 pass 62 pass
63 return prev_error_mode 63 return prev_error_mode
64 64
65 65
66 def RunProcess(verbose, timeout, args, **rest): 66 def RunProcess(verbose, timeout, args, **rest):
67 if verbose: print "#", " ".join(args)
68 popen_args = args
69 prev_error_mode = SEM_INVALID_VALUE
70 if utils.IsWindows():
71 popen_args = subprocess.list2cmdline(args)
72 # Try to change the error mode to avoid dialogs on fatal errors. Don't
73 # touch any existing error mode flags by merging the existing error mode.
74 # See http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx.
75 error_mode = SEM_NOGPFAULTERRORBOX
76 prev_error_mode = Win32SetErrorMode(error_mode)
77 Win32SetErrorMode(error_mode | prev_error_mode)
78 process = subprocess.Popen(
79 shell=utils.IsWindows(),
80 args=popen_args,
81 **rest
82 )
83 if (utils.IsWindows() and prev_error_mode != SEM_INVALID_VALUE):
84 Win32SetErrorMode(prev_error_mode)
85 # Compute the end time - if the process crosses this limit we
86 # consider it timed out.
87 if timeout is None: end_time = None
88 else: end_time = time.time() + timeout
89 timed_out = False
90 # Repeatedly check the exit code from the process in a
91 # loop and keep track of whether or not it times out.
92 exit_code = None
93 sleep_time = INITIAL_SLEEP_TIME
94 try: 67 try:
68 if verbose: print "#", " ".join(args)
69 popen_args = args
70 prev_error_mode = SEM_INVALID_VALUE
71 if utils.IsWindows():
72 popen_args = subprocess.list2cmdline(args)
73 # Try to change the error mode to avoid dialogs on fatal errors. Don't
74 # touch any existing error mode flags by merging the existing error mode.
75 # See http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx.
76 error_mode = SEM_NOGPFAULTERRORBOX
77 prev_error_mode = Win32SetErrorMode(error_mode)
78 Win32SetErrorMode(error_mode | prev_error_mode)
79 process = subprocess.Popen(
80 shell=utils.IsWindows(),
81 args=popen_args,
82 **rest
83 )
84 if (utils.IsWindows() and prev_error_mode != SEM_INVALID_VALUE):
85 Win32SetErrorMode(prev_error_mode)
86 # Compute the end time - if the process crosses this limit we
87 # consider it timed out.
88 if timeout is None: end_time = None
89 else: end_time = time.time() + timeout
90 timed_out = False
91 # Repeatedly check the exit code from the process in a
92 # loop and keep track of whether or not it times out.
93 exit_code = None
94 sleep_time = INITIAL_SLEEP_TIME
95 while exit_code is None: 95 while exit_code is None:
96 if (not end_time is None) and (time.time() >= end_time): 96 if (not end_time is None) and (time.time() >= end_time):
97 # Kill the process and wait for it to exit. 97 # Kill the process and wait for it to exit.
98 KillProcessWithID(process.pid) 98 KillProcessWithID(process.pid)
99 exit_code = process.wait() 99 exit_code = process.wait()
100 timed_out = True 100 timed_out = True
101 else: 101 else:
102 exit_code = process.poll() 102 exit_code = process.poll()
103 time.sleep(sleep_time) 103 time.sleep(sleep_time)
104 sleep_time = sleep_time * SLEEP_TIME_FACTOR 104 sleep_time = sleep_time * SLEEP_TIME_FACTOR
(...skipping 19 matching lines...) Expand all
124 try: 124 try:
125 os.unlink(name) 125 os.unlink(name)
126 return 126 return
127 except OSError, e: 127 except OSError, e:
128 retry_count += 1 128 retry_count += 1
129 time.sleep(retry_count * 0.1) 129 time.sleep(retry_count * 0.1)
130 PrintError("os.unlink() " + str(e)) 130 PrintError("os.unlink() " + str(e))
131 131
132 132
133 def Execute(args, verbose=False, timeout=None): 133 def Execute(args, verbose=False, timeout=None):
134 args = [ c for c in args if c != "" ]
135 (fd_out, outname) = tempfile.mkstemp()
136 (fd_err, errname) = tempfile.mkstemp()
137 try: 134 try:
135 args = [ c for c in args if c != "" ]
136 (fd_out, outname) = tempfile.mkstemp()
137 (fd_err, errname) = tempfile.mkstemp()
138 (exit_code, timed_out) = RunProcess( 138 (exit_code, timed_out) = RunProcess(
139 verbose, 139 verbose,
140 timeout, 140 timeout,
141 args=args, 141 args=args,
142 stdout=fd_out, 142 stdout=fd_out,
143 stderr=fd_err 143 stderr=fd_err
144 ) 144 )
145 except KeyboardInterrupt:
146 raise
145 except: 147 except:
146 raise 148 raise
147 os.close(fd_out) 149 finally:
148 os.close(fd_err) 150 os.close(fd_out)
149 out = file(outname).read() 151 os.close(fd_err)
150 errors = file(errname).read() 152 out = file(outname).read()
151 CheckedUnlink(outname) 153 errors = file(errname).read()
152 CheckedUnlink(errname) 154 CheckedUnlink(outname)
155 CheckedUnlink(errname)
153 return output.Output(exit_code, timed_out, out, errors) 156 return output.Output(exit_code, timed_out, out, errors)
OLDNEW
« no previous file with comments | « tools/run-tests.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698