| 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 waterfall import extractors | 7 from waterfall import extractors |
| 8 from waterfall.extractor import Extractor | 8 from waterfall.extractor import Extractor |
| 9 from waterfall.test import wf_testcase | 9 from waterfall.test import wf_testcase |
| 10 | 10 |
| 11 | 11 |
| 12 class ExtractorsTest(wf_testcase.WaterfallTestCase): | 12 class ExtractorsTest(wf_testcase.WaterfallTestCase): |
| 13 | 13 |
| 14 def _RunTest(self, failure_log, extractor_class, expected_signal_json, | 14 def _RunTest(self, failure_log, extractor_class, expected_signal_json, |
| 15 bot='builder1', master='master1'): | 15 bot='builder1', master='master1'): |
| 16 signal = extractor_class().Extract( | 16 signal = extractor_class().Extract( |
| 17 failure_log, 'suite.test', 'step', bot, master) | 17 failure_log, 'suite.test', 'step', bot, master) |
| 18 |
| 18 self.assertEqual(expected_signal_json, signal.ToDict()) | 19 self.assertEqual(expected_signal_json, signal.ToDict()) |
| 19 | 20 |
| 20 def testGeneralExtractor(self): | 21 def testGeneralExtractor(self): |
| 21 failure_log = textwrap.dedent(""" | 22 failure_log = textwrap.dedent(""" |
| 22 blabla WARNING: bla bla a/b/c.cc:20 | 23 blabla WARNING: bla bla a/b/c.cc:20 |
| 23 | 24 |
| 24 blabla d/e/f.cc:30 | 25 blabla d/e/f.cc:30 |
| 25 blabla""") | 26 blabla""") |
| 26 expected_signal_json = { | 27 expected_signal_json = { |
| 27 'files': { | 28 'files': { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 'keywords': {} | 279 'keywords': {} |
| 279 } | 280 } |
| 280 | 281 |
| 281 self._RunTest( | 282 self._RunTest( |
| 282 failure_log, extractors.GeneralExtractor, expected_signal_json) | 283 failure_log, extractors.GeneralExtractor, expected_signal_json) |
| 283 | 284 |
| 284 def testCompileStepExtractor(self): | 285 def testCompileStepExtractor(self): |
| 285 failure_log = textwrap.dedent(""" | 286 failure_log = textwrap.dedent(""" |
| 286 [1832/2467 | 117.498] CXX obj/a/b/test.file.o | 287 [1832/2467 | 117.498] CXX obj/a/b/test.file.o |
| 287 blabla... | 288 blabla... |
| 288 FAILED: /b/build/goma/gomacc ... ../../a/b/c.cc ... obj/a/b/test.c.o | 289 FAILED: obj/a/b/test.c.o |
| 290 /b/build/goma/gomacc blabla ... -c ../../a/b/c.cc -o obj/a/b/test.c.o |
| 289 ../../a/b/c.cc:307:44: error: no member 'kEnableExtensionInfoDialog' ... | 291 ../../a/b/c.cc:307:44: error: no member 'kEnableExtensionInfoDialog' ... |
| 290 1 error generated. | 292 1 error generated. |
| 291 x/y/not_in_signal.cc | 293 x/y/not_in_signal.cc |
| 292 FAILED: /b/build/goma/gomacc ... ../../a/b/x.cc ... obj/a/b/test.c.o | 294 FAILED: obj/a/b/test.d.o |
| 295 /b/build/goma/gomacc blabla ... -c ../../a/b/d.cc -o obj/a/b/test.d.o |
| 293 ../../a/b/d.cc:123:44: error: no member 'kEnableExtensionInfoDialog' ... | 296 ../../a/b/d.cc:123:44: error: no member 'kEnableExtensionInfoDialog' ... |
| 294 blabla... | 297 blabla... |
| 295 FAILED: /b/build/goma/gomacc ... ../../a/b/x.cc ... obj/a/b/test.c.o | 298 1 error generated. |
| 299 FAILED: obj/a/b/test.e.o |
| 300 /b/build/goma/gomacc ... ../../a/b/e.cc ... obj/a/b/test.e.o |
| 296 ../../a/b/e.cc:79:44: error: no member 'kEnableExtensionInfoDialog' ... | 301 ../../a/b/e.cc:79:44: error: no member 'kEnableExtensionInfoDialog' ... |
| 297 blabla... | 302 blabla... |
| 298 ninja: build stopped: subcommand failed. | 303 ninja: build stopped: subcommand failed. |
| 299 | 304 |
| 300 /b/build/goma/goma_ctl.sh stat | 305 /b/build/goma/goma_ctl.sh stat |
| 301 blabla...""") | 306 blabla...""") |
| 302 expected_signal_json = { | 307 expected_signal_json = { |
| 303 'files': { | 308 'files': { |
| 304 'a/b/c.cc': [307], | 309 'a/b/c.cc': [307], |
| 305 'a/b/d.cc': [123], | 310 'a/b/d.cc': [123], |
| 306 'a/b/e.cc': [79] | 311 'a/b/e.cc': [79] |
| 307 }, | 312 }, |
| 308 'keywords': {} | 313 'keywords': {} |
| 309 } | 314 } |
| 310 | 315 |
| 311 self._RunTest( | 316 self._RunTest( |
| 312 failure_log, extractors.CompileStepExtractor, expected_signal_json) | 317 failure_log, extractors.CompileStepExtractor, expected_signal_json) |
| 313 | 318 |
| 314 def testCompileStepExtractorExtractFailedCompileTargetsLinux(self): | 319 def testCompileStepExtractorExtractFailedCompileTargetsLinux(self): |
| 315 failure_log = textwrap.dedent(""" | 320 failure_log = textwrap.dedent(""" |
| 316 [1832/2467 | 117.498] CXX obj/a/b/test.file.o | 321 [1832/2467 | 117.498] CXX obj/a/b/test.file.o |
| 317 blabla... | 322 blabla... |
| 318 FAILED: /b/build/goma/gomacc ... -c ../../a/b/c.cc -o obj/a/b/c.o | 323 FAILED: obj/a/b/c.o |
| 324 /b/build/goma/gomacc ... -c ../../a/b/c.cc -o obj/a/b/c.o |
| 319 ../../a/b/c.cc:307:44: error: no member 'kEnableExtensionInfoDialog' ... | 325 ../../a/b/c.cc:307:44: error: no member 'kEnableExtensionInfoDialog' ... |
| 320 1 error generated. | 326 1 error generated. |
| 321 x/y/not_in_signal.cc | 327 x/y/not_in_signal.cc |
| 322 FAILED: /b/build/goma/gomacc ... -c ../../a/b/x.cc -o obj/a/b/x.o | 328 FAILED: obj/a/b/x.o |
| 329 /b/build/goma/gomacc ... -c ../../a/b/x.cc -o obj/a/b/x.o |
| 323 ../../a/b/d.cc:123:44: error: no member 'kEnableExtensionInfoDialog' ... | 330 ../../a/b/d.cc:123:44: error: no member 'kEnableExtensionInfoDialog' ... |
| 324 blabla... | 331 blabla... |
| 325 FAILED: /b/build/goma/gomacc ... -c ../../a/b/x.cc -o obj/a/b/x.o | 332 1 error generated. |
| 326 ../../a/b/e.cc:79:44: error: no member 'kEnableExtensionInfoDialog' ... | 333 FAILED: target.exe |
| 334 blabla -o not_this blabla gomacc ... -o target.exe |
| 327 blabla... | 335 blabla... |
| 328 FAILED: blabla -o not_this blabla gomacc ... -o target.exe | 336 1 error generated. |
| 329 blabla... | 337 blabla |
| 330 FAILED: blabla -o not_this blabla -c not_this.cc -o not_this.o | 338 FAILED: notgoma.exe |
| 339 blabla -c blabla.c -o blabla.o |
| 340 blabla |
| 331 ninja: build stopped: subcommand failed. | 341 ninja: build stopped: subcommand failed. |
| 332 | 342 |
| 333 /b/build/goma/goma_ctl.sh stat | 343 /b/build/goma/goma_ctl.sh stat |
| 334 blabla...""") | 344 blabla...""") |
| 335 expected_signal_json = { | 345 expected_signal_json = { |
| 336 'files': { | 346 'files': { |
| 337 'a/b/c.cc': [307], | 347 'a/b/c.cc': [307], |
| 338 'a/b/d.cc': [123], | 348 'a/b/d.cc': [123], |
| 339 'a/b/e.cc': [79] | |
| 340 }, | 349 }, |
| 341 'keywords': {}, | 350 'keywords': {}, |
| 342 'failed_targets': [ | 351 'failed_targets': [ |
| 343 { | 352 { |
| 344 'source': '../../a/b/c.cc', | 353 'source': '../../a/b/c.cc', |
| 345 'target': 'obj/a/b/c.o', | 354 'target': 'obj/a/b/c.o', |
| 346 }, | 355 }, |
| 347 { | 356 { |
| 348 'source': '../../a/b/x.cc', | 357 'source': '../../a/b/x.cc', |
| 349 'target': 'obj/a/b/x.o', | 358 'target': 'obj/a/b/x.o', |
| (...skipping 30 matching lines...) Expand all Loading... |
| 380 ] | 389 ] |
| 381 } | 390 } |
| 382 | 391 |
| 383 self._RunTest( | 392 self._RunTest( |
| 384 failure_log, extractors.CompileStepExtractor, expected_signal_json, | 393 failure_log, extractors.CompileStepExtractor, expected_signal_json, |
| 385 'builder2', 'master2') | 394 'builder2', 'master2') |
| 386 | 395 |
| 387 def testCompileStepExtractorExtractFailedLinkTargetsLinux(self): | 396 def testCompileStepExtractorExtractFailedLinkTargetsLinux(self): |
| 388 failure_log = textwrap.dedent(""" | 397 failure_log = textwrap.dedent(""" |
| 389 [5430/5600] blabla | 398 [5430/5600] blabla |
| 390 FAILED: python blabla clang++ -o a/b.nexe blabla | 399 FAILED: a/b.nexe |
| 400 python blabla clang++ -o a/b.nexe blabla |
| 391 blabla | 401 blabla |
| 392 blabla.Error: FAILED with blabla | 402 blabla.Error: FAILED with blabla |
| 393 FAILED: blabla gomacc -o "target with spaces and quotes" blabla | 403 FAILED: "target with spaces and quotes" |
| 404 blabla gomacc -o "target with spaces and quotes" blabla |
| 394 ninja: build stopped: subcommand failed.""") | 405 ninja: build stopped: subcommand failed.""") |
| 395 expected_signal_json = { | 406 expected_signal_json = { |
| 396 'files': {}, | 407 'files': {}, |
| 397 'keywords': {}, | 408 'keywords': {}, |
| 398 'failed_targets': [ | 409 'failed_targets': [ |
| 399 { | 410 { |
| 400 'target': 'a/b.nexe' | 411 'target': 'a/b.nexe' |
| 401 }, | 412 }, |
| 402 { | 413 { |
| 403 'target': '"target with spaces and quotes"' | 414 'target': '"target with spaces and quotes"' |
| 404 } | 415 } |
| 405 ] | 416 ] |
| 406 } | 417 } |
| 407 | 418 |
| 408 self._RunTest( | 419 self._RunTest( |
| 409 failure_log, extractors.CompileStepExtractor, expected_signal_json, | 420 failure_log, extractors.CompileStepExtractor, expected_signal_json, |
| 410 'builder2', 'master2') | 421 'builder2', 'master2') |
| 411 | 422 |
| 412 def testCompileStepExtractorExtractFailedCompileTargetsWindows(self): | 423 def testCompileStepExtractorExtractFailedCompileTargetsWindows(self): |
| 413 failure_log = textwrap.dedent(""" | 424 failure_log = textwrap.dedent(""" |
| 414 [4576/31353] blabla | 425 [4576/31353] blabla |
| 415 FAILED: ninja blabla /c ..\\..\\a\\b\\c.cc /Foa\\b.c.obj blabla | 426 FAILED: a\\b.c.obj |
| 427 ninja blabla /c ..\\..\\a\\b\\c.cc /Foa\\b.c.obj blabla |
| 416 blabla | 428 blabla |
| 417 FAILED: ninja blabla /c ..\\..\\d\\e\\f.cc /Fod\\e\\f\\a.b.obj blabla | 429 1 error generated. |
| 430 FAILED: d\\e\\f\\a.b.obj |
| 431 ninja blabla /c ..\\..\\d\\e\\f.cc /Fod\\e\\f\\a.b.obj blabla |
| 418 blabla | 432 blabla |
| 419 ninja: build stopped: subcommand failed.""") | 433 ninja: build stopped: subcommand failed.""") |
| 420 expected_signal_json = { | 434 expected_signal_json = { |
| 421 'files': {}, | 435 'files': {}, |
| 422 'keywords': {}, | 436 'keywords': {}, |
| 423 'failed_targets': [ | 437 'failed_targets': [ |
| 424 { | 438 { |
| 425 'source': '..\\..\\a\\b\\c.cc', | 439 'source': '..\\..\\a\\b\\c.cc', |
| 426 'target': 'a\\b.c.obj', | 440 'target': 'a\\b.c.obj', |
| 427 }, | 441 }, |
| 428 { | 442 { |
| 429 'source': '..\\..\\d\\e\\f.cc', | 443 'source': '..\\..\\d\\e\\f.cc', |
| 430 'target': 'd\\e\\f\\a.b.obj' | 444 'target': 'd\\e\\f\\a.b.obj' |
| 431 }, | 445 }, |
| 432 ] | 446 ] |
| 433 } | 447 } |
| 434 | 448 |
| 435 self._RunTest(failure_log, extractors.CompileStepExtractor, | 449 self._RunTest(failure_log, extractors.CompileStepExtractor, |
| 436 expected_signal_json, 'win_builder', 'win_master') | 450 expected_signal_json, 'win_builder', 'win_master') |
| 437 | 451 |
| 438 def testCompileStepExtractorExtractFailedLinkTargetsWindows(self): | 452 def testCompileStepExtractorExtractFailedLinkTargetsWindows(self): |
| 439 failure_log = textwrap.dedent(""" | 453 failure_log = textwrap.dedent(""" |
| 440 [11428/27088] blabla | 454 [11428/27088] blabla |
| 441 FAILED: blabla link.exe /OUT:test.exe @test.exe.rsp blabla | 455 FAILED: test.exe |
| 456 blabla link.exe /OUT:test.exe @test.exe.rsp blabla |
| 442 ninja: build stopped: subcommand failed.""") | 457 ninja: build stopped: subcommand failed.""") |
| 443 expected_signal_json = { | 458 expected_signal_json = { |
| 444 'files': {}, | 459 'files': {}, |
| 445 'keywords': {}, | 460 'keywords': {}, |
| 446 'failed_targets': [ | 461 'failed_targets': [ |
| 447 { | 462 { |
| 448 'target': 'test.exe' | 463 'target': 'test.exe' |
| 449 } | 464 } |
| 450 ] | 465 ] |
| 451 } | 466 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 | 529 |
| 515 def testCompileStepStrictRegexForCompileFailures(self): | 530 def testCompileStepStrictRegexForCompileFailures(self): |
| 516 | 531 |
| 517 goma_clang_prefix = ( | 532 goma_clang_prefix = ( |
| 518 '/b/build/goma/gomacc ' | 533 '/b/build/goma/gomacc ' |
| 519 '../../third_party/llvm-build/Release+Asserts/bin/clang++ ' | 534 '../../third_party/llvm-build/Release+Asserts/bin/clang++ ' |
| 520 '-MMD -MF') | 535 '-MMD -MF') |
| 521 failure_log = textwrap.dedent(""" | 536 failure_log = textwrap.dedent(""" |
| 522 [1832/2467 | 117.498] CXX obj/a/b/test.file.o | 537 [1832/2467 | 117.498] CXX obj/a/b/test.file.o |
| 523 blabla... | 538 blabla... |
| 524 FAILED: %s obj/a.o.d ... -c a.c -o obj/a.o | 539 FAILED: obj/a.o |
| 525 blalba... | 540 %s obj/a.o.d ... -c a.c -o obj/a.o |
| 526 FAILED: %s obj/d.o.d ... -c d.c -o obj/e.o | 541 blabla... |
| 527 blalba... | 542 1 error generated. |
| 528 FAILED with 1: %s obj/f.o.d -c f.c -o obj/f.o | 543 FAILED with 1: obj/f.o %s obj/f.o.d -c f.c -o obj/f.o |
| 529 ninja: build stopped: subcommand failed. | 544 ninja: build stopped: subcommand failed. |
| 530 | 545 |
| 531 /b/build/goma/goma_ctl.sh stat | 546 /b/build/goma/goma_ctl.sh stat |
| 532 blabla...""" % ( | 547 blabla...""" % (goma_clang_prefix, goma_clang_prefix)) |
| 533 goma_clang_prefix, goma_clang_prefix, goma_clang_prefix)) | |
| 534 expected_signal_json = { | 548 expected_signal_json = { |
| 535 'files': { | 549 'files': {}, |
| 536 'obj/f.o': [], | |
| 537 'f.c': [], | |
| 538 }, | |
| 539 'keywords': {}, | 550 'keywords': {}, |
| 540 'failed_targets': [ | 551 'failed_targets': [ |
| 541 { | 552 { |
| 542 'source': 'a.c', | 553 'source': 'a.c', |
| 543 'target': 'obj/a.o', | 554 'target': 'obj/a.o', |
| 544 }, | 555 }, |
| 545 ] | 556 ] |
| 546 } | 557 } |
| 547 | 558 |
| 548 self._RunTest( | 559 self._RunTest( |
| 549 failure_log, extractors.CompileStepExtractor, expected_signal_json) | 560 failure_log, extractors.CompileStepExtractor, expected_signal_json) |
| 550 | 561 |
| 551 def testCompileStepStrictRegexForLinkFailures(self): | 562 def testCompileStepStrictRegexForLinkFailures(self): |
| 552 | 563 |
| 553 goma_gcc_prefix = ( | 564 goma_gcc_prefix = ( |
| 554 '/b/build/slave/Linux/build/src/build/goma/client/gomacc ' | 565 '/b/build/slave/Linux/build/src/build/goma/client/gomacc ' |
| 555 '/bla/bla/.../bin/arm-linux-androideabi-gcc') | 566 '/bla/bla/.../bin/arm-linux-androideabi-gcc') |
| 556 failure_log = textwrap.dedent(""" | 567 failure_log = textwrap.dedent(""" |
| 557 [1832/2467 | 117.498] CXX obj/a/b/test.file.o | 568 [1832/2467 | 117.498] CXX obj/a/b/test.file.o |
| 558 blabla... | 569 blabla... |
| 559 FAILED: %s -Wl,-z,now ... -o exe -Wl,--start-group obj/a.o ... | 570 FAILED: obj/a.o |
| 571 %s -Wl,-z,now ... -o exe -Wl,--start-group obj/a.o ... |
| 560 blalba... | 572 blalba... |
| 561 FAILED: cd a/b/c; python script.py a b c blabla.... | 573 FAILED: cd a/b/c; python script.py a b c blabla.... |
| 562 blalba... | 574 blalba... |
| 563 ninja: build stopped: subcommand failed. | 575 ninja: build stopped: subcommand failed. |
| 564 | 576 |
| 565 /b/build/goma/goma_ctl.sh stat | 577 /b/build/goma/goma_ctl.sh stat |
| 566 blabla...""" % goma_gcc_prefix) | 578 blabla...""" % goma_gcc_prefix) |
| 567 expected_signal_json = { | 579 expected_signal_json = { |
| 568 'files': { | 580 'files': { |
| 569 }, | 581 }, |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 # step_name: result | 830 # step_name: result |
| 819 '1': '1', | 831 '1': '1', |
| 820 '2': '2', | 832 '2': '2', |
| 821 '32434': '0' | 833 '32434': '0' |
| 822 } | 834 } |
| 823 | 835 |
| 824 for step_name, expected_result in cases.iteritems(): | 836 for step_name, expected_result in cases.iteritems(): |
| 825 result = extractors.ExtractSignal( | 837 result = extractors.ExtractSignal( |
| 826 'master', 'bot', step_name, 'test', '') | 838 'master', 'bot', step_name, 'test', '') |
| 827 self.assertEqual(expected_result, result) | 839 self.assertEqual(expected_result, result) |
| OLD | NEW |