Changeset 51405 in webkit


Ignore:
Timestamp:
Nov 25, 2009 7:02:48 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2009-11-25 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Add unit test for mark-fixed
https://bugs.webkit.org/show_bug.cgi?id=31896

  • Scripts/modules/commands/commandtest.py: Added.
  • Scripts/modules/commands/queries_unittest.py:
  • Scripts/modules/commands/upload_unittest.py: Added.
  • Scripts/modules/mock_bugzillatool.py:
  • Scripts/run-webkit-unittests:
Location:
trunk/WebKitTools
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r51404 r51405  
     12009-11-25  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Add unit test for mark-fixed
     6        https://bugs.webkit.org/show_bug.cgi?id=31896
     7
     8        * Scripts/modules/commands/commandtest.py: Added.
     9        * Scripts/modules/commands/queries_unittest.py:
     10        * Scripts/modules/commands/upload_unittest.py: Added.
     11        * Scripts/modules/mock_bugzillatool.py:
     12        * Scripts/run-webkit-unittests:
     13
    1142009-11-25  Adam Barth  <abarth@webkit.org>
    215
  • trunk/WebKitTools/Scripts/modules/commands/commandtest.py

    r51404 r51405  
    2929import unittest
    3030
    31 from modules.commands.queries import *
    32 from modules.mock_bugzillatool import *
     31from modules.mock_bugzillatool import MockBugzillaTool
    3332from modules.outputcapture import OutputCapture
    3433
    35 class QueryCommandsTest(unittest.TestCase):
    36     def _assert_execute_outputs(self, command, command_args, expected_stdout, expected_stderr = ""):
     34class CommandsTest(unittest.TestCase):
     35    def assert_execute_outputs(self, command, command_args, expected_stdout, expected_stderr=""):
    3736        capture = OutputCapture()
    3837        capture.capture_output()
     
    4140        self.assertEqual(stdout_string, expected_stdout)
    4241        self.assertEqual(expected_stderr, expected_stderr)
    43 
    44     def test_bugs_to_commit(self):
    45         self._assert_execute_outputs(BugsToCommit(), None, "42\n75\n")
    46 
    47     def test_patches_to_commit(self):
    48         expected_stdout = "http://example.com/197\nhttp://example.com/128\n"
    49         expected_stderr = "Patches in commit queue:\n"
    50         self._assert_execute_outputs(PatchesToCommit(), None, expected_stdout, expected_stderr)
    51 
    52     def test_reviewed_patches(self):
    53         expected_stdout = "http://example.com/197\nhttp://example.com/128\n"
    54         self._assert_execute_outputs(ReviewedPatches(), [42], expected_stdout)
    55 
    56     def test_tree_status(self):
    57         expected_stdout = "ok   : Builder1\nok   : Builder2\n"
    58         self._assert_execute_outputs(TreeStatus(), None, expected_stdout)
  • trunk/WebKitTools/Scripts/modules/commands/queries_unittest.py

    r51381 r51405  
    2929import unittest
    3030
     31from modules.commands.commandtest import CommandsTest
    3132from modules.commands.queries import *
    32 from modules.mock_bugzillatool import *
    33 from modules.outputcapture import OutputCapture
    3433
    35 class QueryCommandsTest(unittest.TestCase):
    36     def _assert_execute_outputs(self, command, command_args, expected_stdout, expected_stderr = ""):
    37         capture = OutputCapture()
    38         capture.capture_output()
    39         command.execute(None, command_args, MockBugzillaTool())
    40         (stdout_string, stderr_string) = capture.restore_output()
    41         self.assertEqual(stdout_string, expected_stdout)
    42         self.assertEqual(expected_stderr, expected_stderr)
    43 
     34class QueryCommandsTest(CommandsTest):
    4435    def test_bugs_to_commit(self):
    45         self._assert_execute_outputs(BugsToCommit(), None, "42\n75\n")
     36        self.assert_execute_outputs(BugsToCommit(), None, "42\n75\n")
    4637
    4738    def test_patches_to_commit(self):
    4839        expected_stdout = "http://example.com/197\nhttp://example.com/128\n"
    4940        expected_stderr = "Patches in commit queue:\n"
    50         self._assert_execute_outputs(PatchesToCommit(), None, expected_stdout, expected_stderr)
     41        self.assert_execute_outputs(PatchesToCommit(), None, expected_stdout, expected_stderr)
    5142
    5243    def test_reviewed_patches(self):
    5344        expected_stdout = "http://example.com/197\nhttp://example.com/128\n"
    54         self._assert_execute_outputs(ReviewedPatches(), [42], expected_stdout)
     45        self.assert_execute_outputs(ReviewedPatches(), [42], expected_stdout)
    5546
    5647    def test_tree_status(self):
    5748        expected_stdout = "ok   : Builder1\nok   : Builder2\n"
    58         self._assert_execute_outputs(TreeStatus(), None, expected_stdout)
     49        self.assert_execute_outputs(TreeStatus(), None, expected_stdout)
  • trunk/WebKitTools/Scripts/modules/commands/upload_unittest.py

    r51404 r51405  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
    29 class MockBugzilla():
    30     patch1 = { "id": 197, "bug_id": 42, "url": "http://example.com/197" }
    31     patch2 = { "id": 128, "bug_id": 42, "url": "http://example.com/128" }
     29import unittest
    3230
    33     def fetch_bug_ids_from_commit_queue(self):
    34         return [42, 75]
     31from modules.commands.commandtest import CommandsTest
     32from modules.commands.upload import *
    3533
    36     def fetch_patches_from_commit_queue(self):
    37         return [self.patch1, self.patch2]
    38 
    39     def fetch_reviewed_patches_from_bug(self, bug_id):
    40         if bug_id == 42:
    41             return [self.patch1, self.patch2]
    42         return None
    43 
    44 
    45 class MockBuildBot():
    46     def builder_statuses(self):
    47         return [{
    48             "name": "Builder1",
    49             "is_green": True
    50         }, {
    51             "name": "Builder2",
    52             "is_green": True
    53         }]
    54 
    55 
    56 class MockBugzillaTool():
    57     bugs = MockBugzilla()
    58     buildbot = MockBuildBot()
     34class UploadCommandsTest(CommandsTest):
     35    def test_mark_fixed(self):
     36        self.assert_execute_outputs(MarkFixed(), [43, "Test comment"], "", "")
  • trunk/WebKitTools/Scripts/modules/mock_bugzillatool.py

    r51278 r51405  
    4242        return None
    4343
     44    def close_bug_as_fixed(self, bug_id, comment_text=None):
     45        pass
     46
    4447
    4548class MockBuildBot():
  • trunk/WebKitTools/Scripts/run-webkit-unittests

    r51278 r51405  
    3333from modules.buildbot_unittest import *
    3434from modules.changelogs_unittest import *
     35from modules.commands.upload_unittest import *
    3536from modules.commands.queries_unittest import *
    3637from modules.committers_unittest import *
Note: See TracChangeset for help on using the changeset viewer.