OLD | NEW |
---|---|
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 prev_error_mode = SEM_INVALID_VALUE | 43 prev_error_mode = SEM_INVALID_VALUE |
44 try: | 44 try: |
45 import ctypes | 45 import ctypes |
46 prev_error_mode = \ | 46 prev_error_mode = \ |
47 ctypes.windll.kernel32.SetErrorMode(mode) #@UndefinedVariable | 47 ctypes.windll.kernel32.SetErrorMode(mode) #@UndefinedVariable |
48 except ImportError: | 48 except ImportError: |
49 pass | 49 pass |
50 return prev_error_mode | 50 return prev_error_mode |
51 | 51 |
52 | 52 |
53 def RunProcess(verbose, timeout, args, **rest): | 53 def RunProcess(verbose, timeout, args, additionalEnv): |
Michael Achenbach
2017/04/07 13:02:10
Why not keep **rest? Might be that it's used from
Dan Ehrenberg
2017/04/07 14:06:09
I didn't see any usages in the tree, but anyway, a
|
Michael Achenbach
2017/04/07 13:02:10
nit: additional_env
Dan Ehrenberg
2017/04/07 14:06:09
Done.
|
54 if verbose: print "#", " ".join(args) | 54 if verbose: print "#", " ".join(args) |
55 popen_args = args | 55 popen_args = args |
56 prev_error_mode = SEM_INVALID_VALUE | 56 prev_error_mode = SEM_INVALID_VALUE |
57 if utils.IsWindows(): | 57 if utils.IsWindows(): |
58 popen_args = subprocess.list2cmdline(args) | 58 popen_args = subprocess.list2cmdline(args) |
59 # Try to change the error mode to avoid dialogs on fatal errors. Don't | 59 # Try to change the error mode to avoid dialogs on fatal errors. Don't |
60 # touch any existing error mode flags by merging the existing error mode. | 60 # touch any existing error mode flags by merging the existing error mode. |
61 # See http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx. | 61 # See http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx. |
62 error_mode = SEM_NOGPFAULTERRORBOX | 62 error_mode = SEM_NOGPFAULTERRORBOX |
63 prev_error_mode = Win32SetErrorMode(error_mode) | 63 prev_error_mode = Win32SetErrorMode(error_mode) |
64 Win32SetErrorMode(error_mode | prev_error_mode) | 64 Win32SetErrorMode(error_mode | prev_error_mode) |
65 | 65 |
66 env = os.environ.copy() | 66 env = os.environ.copy() |
67 env.update(additionalEnv) | |
67 # GTest shard information is read by the V8 tests runner. Make sure it | 68 # GTest shard information is read by the V8 tests runner. Make sure it |
68 # doesn't leak into the execution of gtests we're wrapping. Those might | 69 # doesn't leak into the execution of gtests we're wrapping. Those might |
69 # otherwise apply a second level of sharding and as a result skip tests. | 70 # otherwise apply a second level of sharding and as a result skip tests. |
70 env.pop('GTEST_TOTAL_SHARDS', None) | 71 env.pop('GTEST_TOTAL_SHARDS', None) |
71 env.pop('GTEST_SHARD_INDEX', None) | 72 env.pop('GTEST_SHARD_INDEX', None) |
72 | 73 |
73 try: | 74 try: |
74 process = subprocess.Popen( | 75 process = subprocess.Popen( |
75 args=popen_args, | 76 args=popen_args, |
76 stdout=subprocess.PIPE, | 77 stdout=subprocess.PIPE, |
77 stderr=subprocess.PIPE, | 78 stderr=subprocess.PIPE, |
78 env=env, | 79 env=env |
79 **rest | |
80 ) | 80 ) |
81 except Exception as e: | 81 except Exception as e: |
82 sys.stderr.write("Error executing: %s\n" % popen_args) | 82 sys.stderr.write("Error executing: %s\n" % popen_args) |
83 raise e | 83 raise e |
84 | 84 |
85 if (utils.IsWindows() and prev_error_mode != SEM_INVALID_VALUE): | 85 if (utils.IsWindows() and prev_error_mode != SEM_INVALID_VALUE): |
86 Win32SetErrorMode(prev_error_mode) | 86 Win32SetErrorMode(prev_error_mode) |
87 | 87 |
88 def kill_process(process, timeout_result): | 88 def kill_process(process, timeout_result): |
89 timeout_result[0] = True | 89 timeout_result[0] = True |
(...skipping 29 matching lines...) Expand all Loading... | |
119 | 119 |
120 return output.Output( | 120 return output.Output( |
121 process.returncode, | 121 process.returncode, |
122 timeout_result[0], | 122 timeout_result[0], |
123 stdout.decode('utf-8', 'replace').encode('utf-8'), | 123 stdout.decode('utf-8', 'replace').encode('utf-8'), |
124 stderr.decode('utf-8', 'replace').encode('utf-8'), | 124 stderr.decode('utf-8', 'replace').encode('utf-8'), |
125 process.pid, | 125 process.pid, |
126 ) | 126 ) |
127 | 127 |
128 | 128 |
129 def Execute(args, verbose=False, timeout=None): | 129 def Execute(args, verbose=False, timeout=None, env={}): |
Michael Achenbach
2017/04/07 13:02:10
env=None
and then pass
env or {}
Dan Ehrenberg
2017/04/07 14:06:09
Done.
Michael Achenbach
2017/04/11 08:38:36
You didn't do the second part, hence the test erro
Dan Ehrenberg
2017/04/11 11:31:51
This was a result of an overconfident search of so
| |
130 args = [ c for c in args if c != "" ] | 130 args = [ c for c in args if c != "" ] |
131 return RunProcess(verbose, timeout, args=args) | 131 return RunProcess(verbose, timeout, args, env) |
OLD | NEW |