| 560 | return result |
| 561 | |
| 562 | def fail_test(self, condition, dump_difference=True, dump_stdio=True, |
| 563 | dump_stack=True): |
| 564 | if not condition: |
| 565 | return |
| 566 | |
| 567 | if dump_difference and hasattr(self, "difference"): |
| 568 | f = StringIO.StringIO() |
| 569 | self.difference.pprint(f) |
| 570 | annotation("changes caused by the last build command", |
| 571 | f.getvalue()) |
| 572 | |
| 573 | if dump_stdio: |
| 574 | self.dump_stdio() |
| 575 | |
| 576 | if "--preserve" in sys.argv: |
| 577 | print |
| 578 | print "*** Copying the state of working dir into 'failed_test' ***" |
| 579 | print |
| 580 | path = os.path.join(self.original_workdir, "failed_test") |
| 581 | if os.path.isdir(path): |
| 582 | shutil.rmtree(path, ignore_errors=False) |
| 583 | elif os.path.exists(path): |
| 584 | raise "Path " + path + " already exists and is not a directory" |
| 585 | shutil.copytree(self.workdir, path) |
| 586 | print "The failed command was:" |
| 587 | print " ".join(self.last_program_invocation) |
| 588 | |
| 589 | if dump_stack: |
| 590 | annotate_stack_trace() |
| 591 | sys.exit(1) |
| 592 | |
| 593 | # A number of methods below check expectations with actual difference |
| 594 | # between directory trees before and after a build. All the 'expect*' |