def fail_test(self, condition, dump_stdio=True, *args): if not condition: return if hasattr(self, 'difference'): f = StringIO.StringIO() self.difference.pprint(f) annotation("changes caused by the last build command", f.getvalue()) if dump_stdio: self.dump_stdio() if '--preserve' in sys.argv: print print "*** Copying the state of working dir into 'failed_test' ***" print path = os.path.join(self.original_workdir, "failed_test") if os.path.isdir(path): shutil.rmtree(path, ignore_errors=False) elif os.path.exists(path): raise "Path " + path + " already exists and is not a directory"; shutil.copytree(self.workdir, path) at = TestCmd.caller(traceback.extract_stack(), 0) annotation("stacktrace", at) sys.exit(1)