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

Side by Side Diff: appengine/findit/waterfall/test/extractors_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: Addressing comments 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 import textwrap 5 import textwrap
6 6
7 from testing_utils import testing
8 from waterfall import extractors 7 from waterfall import extractors
9 from waterfall import waterfall_config
10 from waterfall.extractor import Extractor 8 from waterfall.extractor import Extractor
9 from waterfall.test import wf_configured_test_case
11 10
12 11
13 class ExtractorsTest(testing.AppengineTestCase): 12 class ExtractorsTest(wf_configured_test_case.WaterfallConfiguredTestCase):
13
14 def setUp(self):
15 super(ExtractorsTest, self).setUp()
stgao 2016/03/31 18:07:13 Is this really needed?
lijeffrey 2016/03/31 22:50:20 Done.
14 16
15 def _RunTest(self, failure_log, extractor_class, expected_signal_json, 17 def _RunTest(self, failure_log, extractor_class, expected_signal_json,
16 bot='bot', master='master'): 18 bot='builder1', master='master1'):
17 signal = extractor_class().Extract( 19 signal = extractor_class().Extract(
18 failure_log, 'suite.test', 'step', bot, master) 20 failure_log, 'suite.test', 'step', bot, master)
19 self.assertEqual(expected_signal_json, signal.ToDict()) 21 self.assertEqual(expected_signal_json, signal.ToDict())
20 22
21 def testGeneralExtractor(self): 23 def testGeneralExtractor(self):
22 failure_log = textwrap.dedent(""" 24 failure_log = textwrap.dedent("""
23 blabla WARNING: bla bla a/b/c.cc:20 25 blabla WARNING: bla bla a/b/c.cc:20
24 26
25 blabla d/e/f.cc:30 27 blabla d/e/f.cc:30
26 blabla""") 28 blabla""")
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 'source': '../../a/b/x.cc', 351 'source': '../../a/b/x.cc',
350 'target': 'obj/a/b/x.o', 352 'target': 'obj/a/b/x.o',
351 }, 353 },
352 { 354 {
353 'target': 'target.exe' 355 'target': 'target.exe'
354 } 356 }
355 ] 357 ]
356 } 358 }
357 359
358 self._RunTest( 360 self._RunTest(
359 failure_log, extractors.CompileStepExtractor, expected_signal_json) 361 failure_log, extractors.CompileStepExtractor, expected_signal_json,
362 'builder2', 'master2')
360 363
361 def testCompileStepExtractorExtractFailedTargetsLinuxOutsideFailure(self): 364 def testCompileStepExtractorExtractFailedTargetsLinuxOutsideFailure(self):
362 failure_log = textwrap.dedent(""" 365 failure_log = textwrap.dedent("""
363 [1780/30023] blabla 366 [1780/30023] blabla
364 FAILED: blabla 367 FAILED: blabla
365 blabla 368 blabla
366 1 error generated. 369 1 error generated.
367 FAILED with 1: blabla gomacc -c a/b.cc -o c/d.o blabla 370 FAILED with 1: blabla gomacc -c a/b.cc -o c/d.o blabla
368 blabla 371 blabla
369 Error: FAILED with 1: blabla 372 Error: FAILED with 1: blabla
370 ninja: build stopped: subcommand failed. 373 ninja: build stopped: subcommand failed.
371 blabla.""") 374 blabla.""")
372 expected_signal_json = { 375 expected_signal_json = {
373 'files': {}, 376 'files': {},
374 'keywords': {}, 377 'keywords': {},
375 'failed_targets': [ 378 'failed_targets': [
376 { 379 {
377 'source': 'a/b.cc', 380 'source': 'a/b.cc',
378 'target': 'c/d.o' 381 'target': 'c/d.o'
379 } 382 }
380 ] 383 ]
381 } 384 }
382 385
383 self._RunTest( 386 self._RunTest(
384 failure_log, extractors.CompileStepExtractor, expected_signal_json) 387 failure_log, extractors.CompileStepExtractor, expected_signal_json,
388 'builder2', 'master2')
385 389
386 def testCompileStepExtractorExtractFailedLinkTargetsLinux(self): 390 def testCompileStepExtractorExtractFailedLinkTargetsLinux(self):
387 failure_log = textwrap.dedent(""" 391 failure_log = textwrap.dedent("""
388 [5430/5600] blabla 392 [5430/5600] blabla
389 FAILED: python blabla clang++ -o a/b.nexe blabla 393 FAILED: python blabla clang++ -o a/b.nexe blabla
390 blabla 394 blabla
391 blabla.Error: FAILED with blabla 395 blabla.Error: FAILED with blabla
392 FAILED: blabla gomacc -o "target with spaces and quotes" blabla 396 FAILED: blabla gomacc -o "target with spaces and quotes" blabla
393 ninja: build stopped: subcommand failed.""") 397 ninja: build stopped: subcommand failed.""")
394 expected_signal_json = { 398 expected_signal_json = {
395 'files': {}, 399 'files': {},
396 'keywords': {}, 400 'keywords': {},
397 'failed_targets': [ 401 'failed_targets': [
398 { 402 {
399 'target': 'a/b.nexe' 403 'target': 'a/b.nexe'
400 }, 404 },
401 { 405 {
402 'target': '"target with spaces and quotes"' 406 'target': '"target with spaces and quotes"'
403 } 407 }
404 ] 408 ]
405 } 409 }
406 410
407 self._RunTest( 411 self._RunTest(
408 failure_log, extractors.CompileStepExtractor, expected_signal_json) 412 failure_log, extractors.CompileStepExtractor, expected_signal_json,
413 'builder2', 'master2')
409 414
410 def testCompileStepExtractorExtractFailedCompileTargetsWindows(self): 415 def testCompileStepExtractorExtractFailedCompileTargetsWindows(self):
411 failure_log = textwrap.dedent(""" 416 failure_log = textwrap.dedent("""
412 [4576/31353] blabla 417 [4576/31353] blabla
413 FAILED: ninja blabla /c ..\\..\\a\\b\\c.cc /Foa\\b.c.obj blabla 418 FAILED: ninja blabla /c ..\\..\\a\\b\\c.cc /Foa\\b.c.obj blabla
414 blabla 419 blabla
415 FAILED: ninja blabla /c ..\\..\\d\\e\\f.cc /Fod\\e\\f\\a.b.obj blabla 420 FAILED: ninja blabla /c ..\\..\\d\\e\\f.cc /Fod\\e\\f\\a.b.obj blabla
416 blabla 421 blabla
417 ninja: build stopped: subcommand failed.""") 422 ninja: build stopped: subcommand failed.""")
418 expected_signal_json = { 423 expected_signal_json = {
419 'files': {}, 424 'files': {},
420 'keywords': {}, 425 'keywords': {},
421 'failed_targets': [ 426 'failed_targets': [
422 { 427 {
423 'source': '..\\..\\a\\b\\c.cc', 428 'source': '..\\..\\a\\b\\c.cc',
424 'target': 'a\\b.c.obj', 429 'target': 'a\\b.c.obj',
425 }, 430 },
426 { 431 {
427 'source': '..\\..\\d\\e\\f.cc', 432 'source': '..\\..\\d\\e\\f.cc',
428 'target': 'd\\e\\f\\a.b.obj' 433 'target': 'd\\e\\f\\a.b.obj'
429 }, 434 },
430 ] 435 ]
431 } 436 }
432 437
433 self._RunTest(failure_log, extractors.CompileStepExtractor, 438 self._RunTest(failure_log, extractors.CompileStepExtractor,
434 expected_signal_json) 439 expected_signal_json, 'win_builder', 'win_master')
435 440
436 def testCompileStepExtractorExtractFailedLinkTargetsWindows(self): 441 def testCompileStepExtractorExtractFailedLinkTargetsWindows(self):
437 failure_log = textwrap.dedent(""" 442 failure_log = textwrap.dedent("""
438 [11428/27088] blabla 443 [11428/27088] blabla
439 FAILED: blabla link.exe /OUT:test.exe @test.exe.rsp blabla 444 FAILED: blabla link.exe /OUT:test.exe @test.exe.rsp blabla
440 ninja: build stopped: subcommand failed.""") 445 ninja: build stopped: subcommand failed.""")
441 expected_signal_json = { 446 expected_signal_json = {
442 'files': {}, 447 'files': {},
443 'keywords': {}, 448 'keywords': {},
444 'failed_targets': [ 449 'failed_targets': [
445 { 450 {
446 'target': 'test.exe' 451 'target': 'test.exe'
447 } 452 }
448 ] 453 ]
449 } 454 }
450 455
451 self._RunTest( 456 self._RunTest(
452 failure_log, extractors.CompileStepExtractor, expected_signal_json) 457 failure_log, extractors.CompileStepExtractor, expected_signal_json,
458 'builder2', 'master2')
453 459
454 def testCompileStepNinjaErrorExtractor(self): 460 def testCompileStepNinjaErrorExtractor(self):
455 """Test ninja error extraction in compile step.""" 461 """Test ninja error extraction in compile step."""
456 failure_log = textwrap.dedent(""" 462 failure_log = textwrap.dedent("""
457 ninja -C /a/b/c/ all -j50 463 ninja -C /a/b/c/ all -j50
458 ninja: Entering directory `../da/b/build/sl/M/' 464 ninja: Entering directory `../da/b/build/sl/M/'
459 ninja: error: '../../r/w/c/sess.js', needed by 'ob/r/w/h.stamp', 465 ninja: error: '../../r/w/c/sess.js', needed by 'ob/r/w/h.stamp',
460 missing and no known rule to make it""") 466 missing and no known rule to make it""")
461 expected_signal_json = { 467 expected_signal_json = {
462 'files': { 468 'files': {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 'a/c/in_signal_5.cc': [], 508 'a/c/in_signal_5.cc': [],
503 'a/c/in_signal_6.cc': [] 509 'a/c/in_signal_6.cc': []
504 }, 510 },
505 'keywords': {} 511 'keywords': {}
506 } 512 }
507 513
508 self._RunTest( 514 self._RunTest(
509 failure_log, extractors.CompileStepExtractor, expected_signal_json, 515 failure_log, extractors.CompileStepExtractor, expected_signal_json,
510 'iOS_Simulator_(dbg)', 'chromium.mac') 516 'iOS_Simulator_(dbg)', 'chromium.mac')
511 517
512 def _MockEnableStrictRegexForCompileLinkFailures(self, enabled):
513 def Mocked_EnableStrictRegexForCompileLinkFailures(*_):
514 return enabled
515 self.mock(waterfall_config, 'EnableStrictRegexForCompileLinkFailures',
516 Mocked_EnableStrictRegexForCompileLinkFailures)
517
518 def testCompileStepStrictRegexForCompileFailures(self): 518 def testCompileStepStrictRegexForCompileFailures(self):
519 self._MockEnableStrictRegexForCompileLinkFailures(True)
520 519
521 goma_clang_prefix = ( 520 goma_clang_prefix = (
522 '/b/build/goma/gomacc ' 521 '/b/build/goma/gomacc '
523 '../../third_party/llvm-build/Release+Asserts/bin/clang++ ' 522 '../../third_party/llvm-build/Release+Asserts/bin/clang++ '
524 '-MMD -MF') 523 '-MMD -MF')
525 failure_log = textwrap.dedent(""" 524 failure_log = textwrap.dedent("""
526 [1832/2467 | 117.498] CXX obj/a/b/test.file.o 525 [1832/2467 | 117.498] CXX obj/a/b/test.file.o
527 blabla... 526 blabla...
528 FAILED: %s obj/a.o.d ... -c a.c -o obj/a.o 527 FAILED: %s obj/a.o.d ... -c a.c -o obj/a.o
529 blalba... 528 blalba...
(...skipping 15 matching lines...) Expand all
545 { 544 {
546 'source': 'a.c', 545 'source': 'a.c',
547 'target': 'obj/a.o', 546 'target': 'obj/a.o',
548 }, 547 },
549 ] 548 ]
550 } 549 }
551 550
552 self._RunTest( 551 self._RunTest(
553 failure_log, extractors.CompileStepExtractor, expected_signal_json) 552 failure_log, extractors.CompileStepExtractor, expected_signal_json)
554 553
555
556 def testCompileStepStrictRegexForLinkFailures(self): 554 def testCompileStepStrictRegexForLinkFailures(self):
557 self._MockEnableStrictRegexForCompileLinkFailures(True)
558 555
559 goma_gcc_prefix = ( 556 goma_gcc_prefix = (
560 '/b/build/slave/Linux/build/src/build/goma/client/gomacc ' 557 '/b/build/slave/Linux/build/src/build/goma/client/gomacc '
561 '/bla/bla/.../bin/arm-linux-androideabi-gcc') 558 '/bla/bla/.../bin/arm-linux-androideabi-gcc')
562 failure_log = textwrap.dedent(""" 559 failure_log = textwrap.dedent("""
563 [1832/2467 | 117.498] CXX obj/a/b/test.file.o 560 [1832/2467 | 117.498] CXX obj/a/b/test.file.o
564 blabla... 561 blabla...
565 FAILED: %s -Wl,-z,now ... -o exe -Wl,--start-group obj/a.o ... 562 FAILED: %s -Wl,-z,now ... -o exe -Wl,--start-group obj/a.o ...
566 blalba... 563 blalba...
567 FAILED: cd a/b/c; python script.py a b c blabla.... 564 FAILED: cd a/b/c; python script.py a b c blabla....
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 # step_name: result 821 # step_name: result
825 '1': '1', 822 '1': '1',
826 '2': '2', 823 '2': '2',
827 '32434': '0' 824 '32434': '0'
828 } 825 }
829 826
830 for step_name, expected_result in cases.iteritems(): 827 for step_name, expected_result in cases.iteritems():
831 result = extractors.ExtractSignal( 828 result = extractors.ExtractSignal(
832 'master', 'bot', step_name, 'test', '') 829 'master', 'bot', step_name, 'test', '')
833 self.assertEqual(expected_result, result) 830 self.assertEqual(expected_result, result)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698