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, additional_env, **rest): |
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(additional_env) |
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, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 120 |
120 return output.Output( | 121 return output.Output( |
121 process.returncode, | 122 process.returncode, |
122 timeout_result[0], | 123 timeout_result[0], |
123 stdout.decode('utf-8', 'replace').encode('utf-8'), | 124 stdout.decode('utf-8', 'replace').encode('utf-8'), |
124 stderr.decode('utf-8', 'replace').encode('utf-8'), | 125 stderr.decode('utf-8', 'replace').encode('utf-8'), |
125 process.pid, | 126 process.pid, |
126 ) | 127 ) |
127 | 128 |
128 | 129 |
129 def Execute(args, verbose=False, timeout=None): | 130 def Execute(args, verbose=False, timeout=None, env=None): |
130 args = [ c for c in args if c != "" ] | 131 args = [ c for c in args if c != "" ] |
131 return RunProcess(verbose, timeout, args=args) | 132 return RunProcess(verbose, timeout, args, env or {}) |
OLD | NEW |