Changeset 51362 in webkit
- Timestamp:
- Nov 24, 2009 3:19:28 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r51357 r51362 1 2009-11-24 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 queries_unittest.py should test command output 6 https://bugs.webkit.org/show_bug.cgi?id=31845 7 8 * Scripts/modules/commands/queries_unittest.py: 9 - Capture stdout and stderr and compare with expected strings. 10 1 11 2009-11-24 Simon Fraser <simon.fraser@apple.com> 2 12 -
trunk/WebKitTools/Scripts/modules/commands/queries_unittest.py
r51278 r51362 28 28 29 29 import unittest 30 from StringIO import StringIO 30 31 31 32 from modules.commands.queries import * … … 33 34 34 35 class QueryCommandsTest(unittest.TestCase): 36 def _capture_output_with_name(output_name): 37 self.saved_outputs[output_name] = getattr(sys, output_name) 38 setattr(sys, output_name, StringIO.StringIO()) 39 40 def _release_output_with_name(output_name): 41 captured_output = getattr(sys, output_name).getvalue() 42 setattr(sys, output_name, self.saved_outputs[output_name]) 43 del self.saved_outputs[output_name] 44 return captured_output 45 46 def _capture_output(self): 47 self._capture_output_with_name("stdout") 48 self._capture_output_with_name("stderr") 49 50 def _restore_output(self): 51 return (self._release_output_with_name("stdout"), self._release_output_with_name("stderr")) 52 53 def _assert_execute_outputs(self, command, command_args, expected_stdout, expected_stderr = ""): 54 self._capture_output() 55 command.execute(None, command_args, MockBugzillaTool()) 56 (stdout_string, stderr_string) = self._restore_output() 57 self.assertEqual(stdout_string, expected_stdout) 58 self.assertEqual(expected_stderr, expected_stderr) 59 35 60 def test_bugs_to_commit(self): 36 BugsToCommit().execute(None, None, MockBugzillaTool())61 self._assert_execute_outputs(BugsToCommit(), None, "42\n75\n") 37 62 38 63 def test_patches_to_commit(self): 39 PatchesToCommit().execute(None, None, MockBugzillaTool()) 64 expected_stdout = "http://example.com/197\nhttp://example.com/128\n" 65 expected_stderr = "Patches in commit queue:\n" 66 self._assert_execute_outputs(PatchesToCommit(), None, expected_stdout, expected_stderr) 40 67 41 68 def test_reviewed_patches(self): 42 args = [42]43 ReviewedPatches().execute(None, args, MockBugzillaTool())69 expected_stdout = "http://example.com/197\nhttp://example.com/128\n" 70 self._assert_execute_outputs(ReviewedPatches(), [42], expected_stdout) 44 71 45 72 def test_tree_status(self): 46 TreeStatus().execute(None, None, MockBugzillaTool()) 73 expected_stdout = "ok : Builder1\nok : Builder2\n" 74 self._assert_execute_outputs(TreeStatus(), None, expected_stdout)
Note: See TracChangeset
for help on using the changeset viewer.