Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 7 from testing_utils import testing |
| 8 from waterfall import extractors | 8 from waterfall import extractors |
| 9 from waterfall import waterfall_config | |
| 9 from waterfall.extractor import Extractor | 10 from waterfall.extractor import Extractor |
| 10 | 11 |
| 11 | 12 |
| 12 class ExtractorsTest(testing.AppengineTestCase): | 13 class ExtractorsTest(testing.AppengineTestCase): |
| 13 | 14 |
| 14 def _RunTest(self, failure_log, extractor_class, expected_signal_json, | 15 def _RunTest(self, failure_log, extractor_class, expected_signal_json, |
| 15 bot='bot', master='master'): | 16 bot='bot', master='master'): |
| 16 signal = extractor_class().Extract( | 17 signal = extractor_class().Extract( |
| 17 failure_log, 'suite.test', 'step', bot, master) | 18 failure_log, 'suite.test', 'step', bot, master) |
| 18 self.assertEqual(expected_signal_json, signal.ToDict()) | 19 self.assertEqual(expected_signal_json, signal.ToDict()) |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 'a/c/in_signal_5.cc': [], | 502 'a/c/in_signal_5.cc': [], |
| 502 'a/c/in_signal_6.cc': [] | 503 'a/c/in_signal_6.cc': [] |
| 503 }, | 504 }, |
| 504 'keywords': {} | 505 'keywords': {} |
| 505 } | 506 } |
| 506 | 507 |
| 507 self._RunTest( | 508 self._RunTest( |
| 508 failure_log, extractors.CompileStepExtractor, expected_signal_json, | 509 failure_log, extractors.CompileStepExtractor, expected_signal_json, |
| 509 'iOS_Simulator_(dbg)', 'chromium.mac') | 510 'iOS_Simulator_(dbg)', 'chromium.mac') |
| 510 | 511 |
| 512 def testCompileStepStrictRegexForCompileFailures(self): | |
| 513 def Mocked_EnableStrictRegexForCompileLinkFailures(*_): | |
| 514 return True | |
| 515 self.mock(waterfall_config, 'EnableStrictRegexForCompileLinkFailures', | |
| 516 Mocked_EnableStrictRegexForCompileLinkFailures) | |
| 517 | |
| 518 goma_clang_prefix = ( | |
| 519 '/b/build/goma/gomacc ' | |
| 520 '../../third_party/llvm-build/Release+Asserts/bin/clang++ ' | |
| 521 '-MMD -MF') | |
| 522 failure_log = textwrap.dedent(""" | |
| 523 [1832/2467 | 117.498] CXX obj/a/b/test.file.o | |
| 524 blabla... | |
| 525 FAILED: %s obj/a.o.d ... -c a.c -o obj/a.o | |
| 526 blalba... | |
| 527 FAILED: %s obj/b.o.d ... -c a.c -o obj/c.o | |
| 528 blalba... | |
| 529 FAILED with 1: %s obj/f.o.d -c f.c -o obj/f.o | |
| 530 ninja: build stopped: subcommand failed. | |
| 531 | |
| 532 /b/build/goma/goma_ctl.sh stat | |
| 533 blabla...""" % ( | |
| 534 goma_clang_prefix, goma_clang_prefix, goma_clang_prefix)) | |
| 535 expected_signal_json = { | |
| 536 'files': { | |
| 537 'obj/f.o': [], | |
| 538 'f.c': [], | |
| 539 }, | |
| 540 'keywords': {}, | |
| 541 'failed_targets': [ | |
| 542 { | |
| 543 'source': 'a.c', | |
| 544 'target': 'obj/a.o', | |
| 545 }, | |
| 546 ] | |
| 547 } | |
| 548 | |
| 549 self._RunTest( | |
| 550 failure_log, extractors.CompileStepExtractor, expected_signal_json) | |
| 551 | |
| 552 | |
| 553 def testCompileStepStrictRegexForLinkFailures(self): | |
| 554 def Mocked_EnableStrictRegexForCompileLinkFailures(*_): | |
| 555 return True | |
| 556 self.mock(waterfall_config, 'EnableStrictRegexForCompileLinkFailures', | |
| 557 Mocked_EnableStrictRegexForCompileLinkFailures) | |
|
chanli
2016/03/15 06:07:49
nit: we can reuse this mock from testCompileStepS
stgao
2016/03/15 18:32:21
Done.
| |
| 558 | |
| 559 goma_clang_prefix = ( | |
| 560 '/b/build/goma/gomacc ' | |
| 561 '../../third_party/llvm-build/Release+Asserts/bin/clang++') | |
| 562 failure_log = textwrap.dedent(""" | |
| 563 [1832/2467 | 117.498] CXX obj/a/b/test.file.o | |
| 564 blabla... | |
| 565 FAILED: %s -Wl,-z,now ... -o exe -Wl,--start-group obj/a.o ... | |
| 566 blalba... | |
| 567 FAILED: cd a/b/c; python script.py a b c blabla.... | |
| 568 blalba... | |
| 569 ninja: build stopped: subcommand failed. | |
| 570 | |
| 571 /b/build/goma/goma_ctl.sh stat | |
| 572 blabla...""" % goma_clang_prefix) | |
| 573 expected_signal_json = { | |
| 574 'files': { | |
| 575 }, | |
| 576 'keywords': {}, | |
| 577 'failed_targets': [ | |
| 578 { | |
| 579 'target': 'exe', | |
| 580 }, | |
| 581 ] | |
| 582 } | |
| 583 | |
| 584 self._RunTest( | |
| 585 failure_log, extractors.CompileStepExtractor, expected_signal_json) | |
| 586 | |
| 511 def testCheckPermExtractor(self): | 587 def testCheckPermExtractor(self): |
| 512 failure_log = textwrap.dedent(""" | 588 failure_log = textwrap.dedent(""" |
| 513 a/b/c.py | 589 a/b/c.py |
| 514 ... | 590 ... |
| 515 FAILED whitespace.txt | 591 FAILED whitespace.txt |
| 516 d/e/f.py | 592 d/e/f.py |
| 517 ...""") | 593 ...""") |
| 518 expected_signal_json = { | 594 expected_signal_json = { |
| 519 'files': { | 595 'files': { |
| 520 'd/e/f.py': [] | 596 'd/e/f.py': [] |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 # step_name: result | 824 # step_name: result |
| 749 '1': '1', | 825 '1': '1', |
| 750 '2': '2', | 826 '2': '2', |
| 751 '32434': '0' | 827 '32434': '0' |
| 752 } | 828 } |
| 753 | 829 |
| 754 for step_name, expected_result in cases.iteritems(): | 830 for step_name, expected_result in cases.iteritems(): |
| 755 result = extractors.ExtractSignal( | 831 result = extractors.ExtractSignal( |
| 756 'master', 'bot', step_name, 'test', '') | 832 'master', 'bot', step_name, 'test', '') |
| 757 self.assertEqual(expected_result, result) | 833 self.assertEqual(expected_result, result) |
| OLD | NEW |