Changeset 51023 in webkit


Ignore:
Timestamp:
Nov 16, 2009 3:02:32 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-16 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Re-factor workqueue_unittest to allow for more than one test.
https://bugs.webkit.org/show_bug.cgi?id=31535

  • Scripts/modules/workqueue_unittest.py:
Location:
trunk/WebKitTools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r51022 r51023  
     12009-11-16  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Re-factor workqueue_unittest to allow for more than one test.
     6        https://bugs.webkit.org/show_bug.cgi?id=31535
     7
     8        * Scripts/modules/workqueue_unittest.py:
     9
    1102009-11-16  Eric Seidel  <eric@webkit.org>
    211
  • trunk/WebKitTools/Scripts/modules/workqueue_unittest.py

    r51018 r51023  
    3535from modules.workqueue import WorkQueue, WorkQueueDelegate
    3636
    37 class WorkQueueTest(unittest.TestCase, WorkQueueDelegate):
    38     def test_trivial(self):
    39         self.set_up()
    40         work_queue = WorkQueue(self)
    41         work_queue.run()
    42         self.assertEquals(self.callbacks, [
    43             'queue_log_path',
    44             'status_host',
    45             'begin_work_queue',
    46             'should_continue_work_queue',
    47             'next_work_item',
    48             'should_proceed_with_work_item',
    49             'work_logs_directory',
    50             'process_work_item',
    51             'should_continue_work_queue'])
    52         self.clean_up()
    53 
    54     def set_up(self):
     37class LoggingDelegate(WorkQueueDelegate):
     38    def __init__(self, test):
     39        self.test = test
    5540        self.callbacks = []
    5641        self.run_before = False
    57         self.temp_dir = tempfile.mkdtemp(suffix="work_queue_test_logs")
    58 
    59     def clean_up(self):
    60         os.path.exists(self.queue_log_path())
    61         os.path.exists(os.path.join(self.work_logs_directory(), "42.log"))
    62         shutil.rmtree(self.temp_dir)
    6342
    6443    def queue_log_path(self):
    6544        self.callbacks.append("queue_log_path")
    66         return os.path.join(self.temp_dir, "queue_log_path")
     45        return os.path.join(self.test.temp_dir, "queue_log_path")
    6746
    6847    def work_logs_directory(self):
    6948        self.callbacks.append("work_logs_directory")
    70         return os.path.join(self.temp_dir, "work_log_path")
     49        return os.path.join(self.test.temp_dir, "work_log_path")
    7150
    7251    def status_host(self):
     
    9069    def should_proceed_with_work_item(self, work_item):
    9170        self.callbacks.append("should_proceed_with_work_item")
    92         self.assertEquals(work_item, "work_item")
     71        self.test.assertEquals(work_item, "work_item")
    9372        return (True, "waiting_message", 42)
    9473
    9574    def process_work_item(self, work_item):
    9675        self.callbacks.append("process_work_item")
    97         self.assertEquals(work_item, "work_item")
     76        self.test.assertEquals(work_item, "work_item")
    9877
    9978    def handle_unexpected_error(self, work_item, message):
    10079        self.callbacks.append("handle_unexpected_error")
    101         self.assertEquals(work_item, "work_item")
     80        self.test.assertEquals(work_item, "work_item")
     81
     82class WorkQueueTest(unittest.TestCase):
     83    def test_trivial(self):
     84        delegate = LoggingDelegate(self)
     85        work_queue = WorkQueue(delegate)
     86        work_queue.run()
     87        self.assertEquals(delegate.callbacks, [
     88            'queue_log_path',
     89            'status_host',
     90            'begin_work_queue',
     91            'should_continue_work_queue',
     92            'next_work_item',
     93            'should_proceed_with_work_item',
     94            'work_logs_directory',
     95            'process_work_item',
     96            'should_continue_work_queue'])
     97        self.assertTrue(os.path.exists(delegate.queue_log_path()))
     98        self.assertTrue(os.path.exists(os.path.join(delegate.work_logs_directory(), "42.log")))
     99
     100    def setUp(self):
     101        self.temp_dir = tempfile.mkdtemp(suffix="work_queue_test_logs")
     102
     103    def tearDown(self):
     104        shutil.rmtree(self.temp_dir)
    102105
    103106
Note: See TracChangeset for help on using the changeset viewer.