| OLD | NEW |
| 1 # Copyright (C) 2011 Google Inc. All rights reserved. | 1 # Copyright (C) 2011 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 # FIXME: This should be unified with MockExecutive2 | 55 # FIXME: This should be unified with MockExecutive2 |
| 56 class MockExecutive(object): | 56 class MockExecutive(object): |
| 57 PIPE = "MOCK PIPE" | 57 PIPE = "MOCK PIPE" |
| 58 STDOUT = "MOCK STDOUT" | 58 STDOUT = "MOCK STDOUT" |
| 59 | 59 |
| 60 @staticmethod | 60 @staticmethod |
| 61 def ignore_error(error): | 61 def ignore_error(error): |
| 62 pass | 62 pass |
| 63 | 63 |
| 64 def __init__(self, should_log=False, should_throw=False, should_throw_when_r
un=None): | 64 def __init__(self, should_log=False, should_throw=False, |
| 65 should_throw_when_run=None, should_return_zero_when_run=None): |
| 65 self._should_log = should_log | 66 self._should_log = should_log |
| 66 self._should_throw = should_throw | 67 self._should_throw = should_throw |
| 67 self._should_throw_when_run = should_throw_when_run or set() | 68 self._should_throw_when_run = should_throw_when_run or set() |
| 69 self._should_return_zero_when_run = should_return_zero_when_run or set() |
| 68 # FIXME: Once executive wraps os.getpid() we can just use a static pid f
or "this" process. | 70 # FIXME: Once executive wraps os.getpid() we can just use a static pid f
or "this" process. |
| 69 self._running_pids = {'test-webkitpy': os.getpid()} | 71 self._running_pids = {'test-webkitpy': os.getpid()} |
| 70 self._proc = None | 72 self._proc = None |
| 71 self.calls = [] | 73 self.calls = [] |
| 72 | 74 |
| 73 def check_running_pid(self, pid): | 75 def check_running_pid(self, pid): |
| 74 return pid in self._running_pids.values() | 76 return pid in self._running_pids.values() |
| 75 | 77 |
| 76 def running_pids(self, process_name_filter): | 78 def running_pids(self, process_name_filter): |
| 77 running_pids = [] | 79 running_pids = [] |
| (...skipping 30 matching lines...) Expand all Loading... |
| 108 if input: | 110 if input: |
| 109 input_string = ", input=%s" % input | 111 input_string = ", input=%s" % input |
| 110 _log.info("MOCK run_command: %s, cwd=%s%s%s" % (args, cwd, env_strin
g, input_string)) | 112 _log.info("MOCK run_command: %s, cwd=%s%s%s" % (args, cwd, env_strin
g, input_string)) |
| 111 output = "MOCK output of child process" | 113 output = "MOCK output of child process" |
| 112 | 114 |
| 113 if self._should_throw_when_run.intersection(args): | 115 if self._should_throw_when_run.intersection(args): |
| 114 raise ScriptError("Exception for %s" % args, output="MOCK command ou
tput") | 116 raise ScriptError("Exception for %s" % args, output="MOCK command ou
tput") |
| 115 | 117 |
| 116 if self._should_throw: | 118 if self._should_throw: |
| 117 raise ScriptError("MOCK ScriptError", output=output) | 119 raise ScriptError("MOCK ScriptError", output=output) |
| 120 |
| 121 if return_exit_code and self._should_return_zero_when_run.intersection(a
rgs): |
| 122 return 0 |
| 123 |
| 118 return output | 124 return output |
| 119 | 125 |
| 120 def cpu_count(self): | 126 def cpu_count(self): |
| 121 return 2 | 127 return 2 |
| 122 | 128 |
| 123 def kill_all(self, process_name): | 129 def kill_all(self, process_name): |
| 124 pass | 130 pass |
| 125 | 131 |
| 126 def kill_process(self, pid): | 132 def kill_process(self, pid): |
| 127 pass | 133 pass |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 if self._run_command_fn: | 195 if self._run_command_fn: |
| 190 return self._run_command_fn(args) | 196 return self._run_command_fn(args) |
| 191 if return_exit_code: | 197 if return_exit_code: |
| 192 return self._exit_code | 198 return self._exit_code |
| 193 if self._exit_code and error_handler: | 199 if self._exit_code and error_handler: |
| 194 script_error = ScriptError(script_args=args, exit_code=self._exit_co
de, output=self._output) | 200 script_error = ScriptError(script_args=args, exit_code=self._exit_co
de, output=self._output) |
| 195 error_handler(script_error) | 201 error_handler(script_error) |
| 196 if return_stderr: | 202 if return_stderr: |
| 197 return self._output + self._stderr | 203 return self._output + self._stderr |
| 198 return self._output | 204 return self._output |
| OLD | NEW |