aboutsummaryrefslogtreecommitdiff
path: root/bestflags/pipeline_worker_test.py
diff options
context:
space:
mode:
authorYuheng Long <yuhenglong@google.com>2013-08-06 14:47:12 -0700
committerChromeBot <chrome-bot@google.com>2013-08-07 14:29:03 -0700
commitf1f606e1c5b559aa264518a89595afd787f12e8a (patch)
treec80955f96832e27cd32af8fae55eb6c303ef8dfd /bestflags/pipeline_worker_test.py
parentccfaf2f382815945c1c883e1cfceb2eba55e28b0 (diff)
downloadtoolchain-utils-f1f606e1c5b559aa264518a89595afd787f12e8a.tar.gz
Encapsulate a couple inner fields in a unittest.
BUG=None TEST=unit testings for the pipeline stage, pipeline workers, generation, steering, task, flag and hill climbing. Change-Id: I5d86c107cb7a0693c97a0cb404c2a89a172ce835 Reviewed-on: https://gerrit-int.chromium.org/42418 Reviewed-by: Simon Que <sque@google.com> Tested-by: Yuheng Long <yuhenglong@google.com> Commit-Queue: Yuheng Long <yuhenglong@google.com>
Diffstat (limited to 'bestflags/pipeline_worker_test.py')
-rw-r--r--bestflags/pipeline_worker_test.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/bestflags/pipeline_worker_test.py b/bestflags/pipeline_worker_test.py
index 4ed6e350..8c8f315c 100644
--- a/bestflags/pipeline_worker_test.py
+++ b/bestflags/pipeline_worker_test.py
@@ -22,7 +22,7 @@ import pipeline_worker
# Pick an integer at random.
-TESTSTAGE = -3
+TEST_STAGE = -3
def MockTaskCostGenerator():
@@ -52,7 +52,7 @@ class PipelineWorkerTest(unittest.TestCase):
# Set up the helper process that holds the helper method.
helper_process = multiprocessing.Process(target=pipeline_worker.Helper,
- args=(TESTSTAGE, {}, helper_queue,
+ args=(TEST_STAGE, {}, helper_queue,
completed_queue,
result_queue))
helper_process.start()
@@ -72,7 +72,7 @@ class PipelineWorkerTest(unittest.TestCase):
# Testing the correctness of having tasks having the same identifier, here
# 1.
for result in results:
- helper_queue.put(MockTask(TESTSTAGE, result, MockTaskCostGenerator()))
+ helper_queue.put(MockTask(TEST_STAGE, result, MockTaskCostGenerator()))
completed_queue.put((2, mock_result[2]))
completed_queue.put((1, mock_result[1]))
@@ -83,12 +83,11 @@ class PipelineWorkerTest(unittest.TestCase):
while results:
task = result_queue.get()
- identifier = task._identifier
- cost = task._cost
+ identifier = task.GetIdentifier(TEST_STAGE)
self.assertTrue(identifier in results)
if identifier in mock_result:
- self.assertTrue(cost, mock_result[identifier])
- results.remove(task._identifier)
+ self.assertTrue(task.GetResult(TEST_STAGE), mock_result[identifier])
+ results.remove(identifier)
def testWorker(self):
""""Test the worker method.
@@ -107,11 +106,11 @@ class PipelineWorkerTest(unittest.TestCase):
mock_tasks = []
for flag, cost in mock_work_tasks.iteritems():
- mock_tasks.append(MockTask(TESTSTAGE, flag, cost))
+ mock_tasks.append(MockTask(TEST_STAGE, flag, cost))
# Submit the mock tasks to the worker.
for mock_task in mock_tasks:
- pipeline_worker.Worker(TESTSTAGE, mock_task, completed_queue,
+ pipeline_worker.Worker(TEST_STAGE, mock_task, completed_queue,
result_queue)
# The tasks, from the output queue, should be the same as the input and
@@ -119,7 +118,7 @@ class PipelineWorkerTest(unittest.TestCase):
for task in mock_tasks:
output = result_queue.get()
self.assertEqual(output, task)
- self.assertTrue(output.Done(TESTSTAGE))
+ self.assertTrue(output.Done(TEST_STAGE))
# The tasks, from the completed_queue, should be defined in the
# mock_work_tasks dictionary.