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

Side by Side Diff: tests/subprocess2_test.py

Issue 6806009: Set returncode to subprocess2.TIMED_OUT instead of -9 when a process times out. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Rephrased docstring Created 9 years, 8 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 | « subprocess2.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unit tests for subprocess2.py.""" 6 """Unit tests for subprocess2.py."""
7 7
8 import optparse 8 import optparse
9 import os 9 import os
10 import sys 10 import sys
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 'stderr': subprocess2.STDOUT, 129 'stderr': subprocess2.STDOUT,
130 } 130 }
131 self.assertEquals(expected, results) 131 self.assertEquals(expected, results)
132 132
133 def test_timeout(self): 133 def test_timeout(self):
134 # It'd be better to not discard stdout. 134 # It'd be better to not discard stdout.
135 out, returncode = subprocess2.call( 135 out, returncode = subprocess2.call(
136 self.exe + ['--sleep', '--stdout'], 136 self.exe + ['--sleep', '--stdout'],
137 timeout=0.01, 137 timeout=0.01,
138 stdout=subprocess2.PIPE) 138 stdout=subprocess2.PIPE)
139 self.assertEquals(-9, returncode) 139 self.assertEquals(subprocess2.TIMED_OUT, returncode)
140 self.assertEquals(['', None], out) 140 self.assertEquals(['', None], out)
141 141
142 def test_void(self): 142 def test_void(self):
143 out = subprocess2.check_output( 143 out = subprocess2.check_output(
144 self.exe + ['--stdout', '--stderr'], 144 self.exe + ['--stdout', '--stderr'],
145 stdout=subprocess2.VOID) 145 stdout=subprocess2.VOID)
146 self.assertEquals(None, out) 146 self.assertEquals(None, out)
147 out = subprocess2.check_output( 147 out = subprocess2.check_output(
148 self.exe + ['--stdout', '--stderr'], 148 self.exe + ['--stdout', '--stderr'],
149 universal_newlines=True, 149 universal_newlines=True,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 do('CCC') 196 do('CCC')
197 if options.sleep: 197 if options.sleep:
198 time.sleep(10) 198 time.sleep(10)
199 return options.return_value 199 return options.return_value
200 200
201 201
202 if __name__ == '__main__': 202 if __name__ == '__main__':
203 if len(sys.argv) > 1 and sys.argv[1] == '--child': 203 if len(sys.argv) > 1 and sys.argv[1] == '--child':
204 sys.exit(child_main(sys.argv[2:])) 204 sys.exit(child_main(sys.argv[2:]))
205 unittest.main() 205 unittest.main()
OLDNEW
« no previous file with comments | « subprocess2.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698