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

Side by Side Diff: appengine/findit/waterfall/test/try_job_util_test.py

Issue 1836293002: [Findit] Adding central config test class for unit tests (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from testing_utils import testing
6
7 from model import wf_analysis_status 5 from model import wf_analysis_status
8 from model.wf_analysis import WfAnalysis
9 from model.wf_try_job import WfTryJob 6 from model.wf_try_job import WfTryJob
10 from waterfall import try_job_util 7 from waterfall import try_job_util
11 from waterfall import waterfall_config 8 from waterfall.test import wf_testcase
12 from waterfall.try_job_type import TryJobType 9 from waterfall.try_job_type import TryJobType
13 10
14 11
15 class _MockRootPipeline(object): 12 class _MockRootPipeline(object):
16 STARTED = False 13 STARTED = False
17 14
18 def __init__(self, *_): 15 def __init__(self, *_):
19 pass 16 pass
20 17
21 def start(self, *_, **__): 18 def start(self, *_, **__):
22 _MockRootPipeline.STARTED = True 19 _MockRootPipeline.STARTED = True
23 20
24 @property 21 @property
25 def pipeline_status_path(self): 22 def pipeline_status_path(self):
26 return 'path' 23 return 'path'
27 24
28 25
29 class TryJobUtilTest(testing.AppengineTestCase): 26 class TryJobUtilTest(wf_testcase.WaterfallTestCase):
30 27
31 def setUp(self): 28 def setUp(self):
32 super(TryJobUtilTest, self).setUp() 29 super(TryJobUtilTest, self).setUp()
33 30
34 def Mocked_GetTrybotForWaterfallBuilder(*_):
35 return 'tryserver.master', 'tryserver.builder'
36 self.mock(waterfall_config, 'GetTrybotForWaterfallBuilder',
37 Mocked_GetTrybotForWaterfallBuilder)
38
39 def testNotNeedANewTryJobIfBuildIsNotCompletedYet(self): 31 def testNotNeedANewTryJobIfBuildIsNotCompletedYet(self):
40 self.mock( 32 self.mock(
41 try_job_util.swarming_tasks_to_try_job_pipeline, 33 try_job_util.swarming_tasks_to_try_job_pipeline,
42 'SwarmingTasksToTryJobPipeline', _MockRootPipeline) 34 'SwarmingTasksToTryJobPipeline', _MockRootPipeline)
43 _MockRootPipeline.STARTED = False 35 _MockRootPipeline.STARTED = False
44 36
45 failure_result_map = try_job_util.ScheduleTryJobIfNeeded( 37 failure_result_map = try_job_util.ScheduleTryJobIfNeeded(
46 {}, build_completed=False) 38 {}, build_completed=False)
47 39
48 self.assertFalse(_MockRootPipeline.STARTED) 40 self.assertFalse(_MockRootPipeline.STARTED)
49 self.assertEqual({}, failure_result_map) 41 self.assertEqual({}, failure_result_map)
50 42
51 def testNotNeedANewTryJobIfBuilderIsNotSupportedYet(self): 43 def testNotNeedANewTryJobIfBuilderIsNotSupportedYet(self):
52 def Mocked_GetTrybotForWaterfallBuilder(*_): 44 master_name = 'master2'
53 return None, None 45 builder_name = 'builder2'
54 self.mock(waterfall_config, 'GetTrybotForWaterfallBuilder',
55 Mocked_GetTrybotForWaterfallBuilder)
56
57 master_name = 'm'
58 builder_name = 'b'
59 build_number = 223 46 build_number = 223
60 failure_info = { 47 failure_info = {
61 'master_name': master_name, 48 'master_name': master_name,
62 'builder_name': builder_name, 49 'builder_name': builder_name,
63 'build_number': build_number, 50 'build_number': build_number,
64 'failed_steps': { 51 'failed_steps': {
65 'compile': { 52 'compile': {
66 'current_failure': 221, 53 'current_failure': 221,
67 'first_failure': 221, 54 'first_failure': 221,
68 'last_pass': 220 55 'last_pass': 220
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 {'target': 'a.exe'}, 381 {'target': 'a.exe'},
395 {'source': 'b.cc', 382 {'source': 'b.cc',
396 'target': 'b.o'}] 383 'target': 'b.o'}]
397 } 384 }
398 } 385 }
399 386
400 self.assertEqual( 387 self.assertEqual(
401 try_job_util._GetFailedTargetsFromSignals(signals, 'm', 'b'), ['a.exe']) 388 try_job_util._GetFailedTargetsFromSignals(signals, 'm', 'b'), ['a.exe'])
402 389
403 def testUseObjectFilesAsFailedTargetIfStrictRegexUsed(self): 390 def testUseObjectFilesAsFailedTargetIfStrictRegexUsed(self):
404 def Mocked_EnableStrictRegexForCompileLinkFailures(*_):
405 return True
406 self.mock(waterfall_config, 'EnableStrictRegexForCompileLinkFailures',
407 Mocked_EnableStrictRegexForCompileLinkFailures)
408
409 signals = { 391 signals = {
410 'compile': { 392 'compile': {
411 'failed_targets': [ 393 'failed_targets': [
412 {'source': 'b.cc', 'target': 'b.o'}, 394 {'source': 'b.cc', 'target': 'b.o'},
413 ] 395 ]
414 } 396 }
415 } 397 }
416 398
417 self.assertEqual( 399 self.assertEqual(
418 try_job_util._GetFailedTargetsFromSignals(signals, 'm', 'b'), ['b.o']) 400 try_job_util._GetFailedTargetsFromSignals(
401 signals, 'master1', 'builder1'),
402 ['b.o'])
OLDNEW
« no previous file with comments | « appengine/findit/waterfall/test/try_job_pipeline_test.py ('k') | appengine/findit/waterfall/test/waterfall_config_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698