| 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 _MockEnableStrictRegexForCompileLinkFailures(self, enabled): |
| 513 def Mocked_EnableStrictRegexForCompileLinkFailures(*_): |
| 514 return enabled |
| 515 self.mock(waterfall_config, 'EnableStrictRegexForCompileLinkFailures', |
| 516 Mocked_EnableStrictRegexForCompileLinkFailures) |
| 517 |
| 518 def testCompileStepStrictRegexForCompileFailures(self): |
| 519 self._MockEnableStrictRegexForCompileLinkFailures(True) |
| 520 |
| 521 goma_clang_prefix = ( |
| 522 '/b/build/goma/gomacc ' |
| 523 '../../third_party/llvm-build/Release+Asserts/bin/clang++ ' |
| 524 '-MMD -MF') |
| 525 failure_log = textwrap.dedent(""" |
| 526 [1832/2467 | 117.498] CXX obj/a/b/test.file.o |
| 527 blabla... |
| 528 FAILED: %s obj/a.o.d ... -c a.c -o obj/a.o |
| 529 blalba... |
| 530 FAILED: %s obj/d.o.d ... -c d.c -o obj/e.o |
| 531 blalba... |
| 532 FAILED with 1: %s obj/f.o.d -c f.c -o obj/f.o |
| 533 ninja: build stopped: subcommand failed. |
| 534 |
| 535 /b/build/goma/goma_ctl.sh stat |
| 536 blabla...""" % ( |
| 537 goma_clang_prefix, goma_clang_prefix, goma_clang_prefix)) |
| 538 expected_signal_json = { |
| 539 'files': { |
| 540 'obj/f.o': [], |
| 541 'f.c': [], |
| 542 }, |
| 543 'keywords': {}, |
| 544 'failed_targets': [ |
| 545 { |
| 546 'source': 'a.c', |
| 547 'target': 'obj/a.o', |
| 548 }, |
| 549 ] |
| 550 } |
| 551 |
| 552 self._RunTest( |
| 553 failure_log, extractors.CompileStepExtractor, expected_signal_json) |
| 554 |
| 555 |
| 556 def testCompileStepStrictRegexForLinkFailures(self): |
| 557 self._MockEnableStrictRegexForCompileLinkFailures(True) |
| 558 |
| 559 goma_gcc_prefix = ( |
| 560 '/b/build/slave/Linux/build/src/build/goma/client/gomacc ' |
| 561 '/bla/bla/.../bin/arm-linux-androideabi-gcc') |
| 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_gcc_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 |