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