<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US"> <head> <title>kate: test_regression.cpp Source File (kate)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org" r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org" r (n 0 s 0 v 0 l 0))' /> <meta name="trademark" content="KDE e.V." /> <meta name="description" content="K Desktop Environment Homepage, KDE.org" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="robots" content="all" /> <link rel="shortcut icon" href="../../favicon.ico" /> <link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" /> </head> <body> <div id="nav_header_top" align="right"> <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a> <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a> <span class="doNotDisplay">::</span> <div id="nav_header_title" align="left">KDE API Reference</div> </div> <div id="nav_header_bottom" align="right"> <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span> <div id="nav_header_bottom_right" style="text-align: left;"> / <a href="../..">API Reference</a> / <a href=".">kate</a> </div> </div> <table id="main" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" class="menuheader" height="0"></td> <td id="contentcolumn" valign="top" rowspan="2" > <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;"> <a name="content"></a> <!-- Generated by Doxygen 1.7.4 --> <div class="header"> <div class="headertitle"> <div class="title">test_regression.cpp</div> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00026"></a>00026 <span class="preprocessor">#include <stdlib.h></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <sys/time.h></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <sys/resource.h></span> <a name="l00029"></a>00029 <span class="preprocessor">#include <sys/types.h></span> <a name="l00030"></a>00030 <span class="preprocessor">#include <unistd.h></span> <a name="l00031"></a>00031 <span class="preprocessor">#include <pwd.h></span> <a name="l00032"></a>00032 <span class="preprocessor">#include <signal.h></span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <span class="preprocessor">#include <kapplication.h></span> <a name="l00035"></a>00035 <span class="preprocessor">#include <kstandarddirs.h></span> <a name="l00036"></a>00036 <span class="preprocessor">#include <qimage.h></span> <a name="l00037"></a>00037 <span class="preprocessor">#include <qfile.h></span> <a name="l00038"></a>00038 <span class="preprocessor">#include "test_regression.h"</span> <a name="l00039"></a>00039 <span class="preprocessor">#include <unistd.h></span> <a name="l00040"></a>00040 <span class="preprocessor">#include <stdio.h></span> <a name="l00041"></a>00041 <a name="l00042"></a>00042 <span class="preprocessor">#include <kaction.h></span> <a name="l00043"></a>00043 <span class="preprocessor">#include <kcmdlineargs.h></span> <a name="l00044"></a>00044 <span class="preprocessor">#include "katefactory.h"</span> <a name="l00045"></a>00045 <span class="preprocessor">#include <kio/job.h></span> <a name="l00046"></a>00046 <span class="preprocessor">#include <kmainwindow.h></span> <a name="l00047"></a>00047 <span class="preprocessor">#include <ksimpleconfig.h></span> <a name="l00048"></a>00048 <span class="preprocessor">#include <kglobalsettings.h></span> <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="preprocessor">#include <qcolor.h></span> <a name="l00051"></a>00051 <span class="preprocessor">#include <qcursor.h></span> <a name="l00052"></a>00052 <span class="preprocessor">#include <qdir.h></span> <a name="l00053"></a>00053 <span class="preprocessor">#include <qevent.h></span> <a name="l00054"></a>00054 <span class="preprocessor">#include <qobject.h></span> <a name="l00055"></a>00055 <span class="preprocessor">#include <qpushbutton.h></span> <a name="l00056"></a>00056 <span class="preprocessor">#include <qscrollview.h></span> <a name="l00057"></a>00057 <span class="preprocessor">#include <qstring.h></span> <a name="l00058"></a>00058 <span class="preprocessor">#include <qregexp.h></span> <a name="l00059"></a>00059 <span class="preprocessor">#include <qtextstream.h></span> <a name="l00060"></a>00060 <span class="preprocessor">#include <qvaluelist.h></span> <a name="l00061"></a>00061 <span class="preprocessor">#include <qwidget.h></span> <a name="l00062"></a>00062 <span class="preprocessor">#include <qfileinfo.h></span> <a name="l00063"></a>00063 <span class="preprocessor">#include <qtimer.h></span> <a name="l00064"></a>00064 <span class="preprocessor">#include <kstatusbar.h></span> <a name="l00065"></a>00065 <span class="preprocessor">#include <qfileinfo.h></span> <a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="preprocessor">#include "katedocument.h"</span> <a name="l00068"></a>00068 <span class="preprocessor">#include "kateview.h"</span> <a name="l00069"></a>00069 <span class="preprocessor">#include <kparts/browserextension.h></span> <a name="l00070"></a>00070 <span class="preprocessor">#include "katejscript.h"</span> <a name="l00071"></a>00071 <span class="preprocessor">#include "katedocumenthelpers.h"</span> <a name="l00072"></a>00072 <span class="preprocessor">#include "kateconfig.h"</span> <a name="l00073"></a>00073 <span class="preprocessor">#include "../interfaces/katecmd.h"</span> <a name="l00074"></a>00074 <a name="l00075"></a>00075 <span class="keyword">using namespace </span>KJS; <a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="preprocessor">#define BASE_DIR_CONFIG "/.testkateregression-3.5"</span> <a name="l00078"></a>00078 <span class="preprocessor"></span> <a name="l00079"></a>00079 <span class="comment">//BEGIN TestJScriptEnv</span> <a name="l00080"></a>00080 <a name="l00081"></a>00081 TestJScriptEnv::TestJScriptEnv(KateDocument *part) { <a name="l00082"></a>00082 ExecState *exec = m_interpreter->globalExec(); <a name="l00083"></a>00083 <a name="l00084"></a>00084 KJS::ObjectImp *wd = wrapDocument(m_interpreter->globalExec(), part); <a name="l00085"></a>00085 KateView *v = <span class="keyword">static_cast<</span>KateView *<span class="keyword">></span>(part->widget()); <a name="l00086"></a>00086 KJS::ObjectImp *wv = <span class="keyword">new</span> KateViewObject(exec, v, wrapView(m_interpreter->globalExec(), v)); <a name="l00087"></a>00087 <a name="l00088"></a>00088 *m_view = KJS::Object(wv); <a name="l00089"></a>00089 *m_document = KJS::Object(wd); <a name="l00090"></a>00090 m_output = <span class="keyword">new</span> <a class="code" href="classOutputObject.html" title="Customizing output to result-files.">OutputObject</a>(exec, part, v); <a name="l00091"></a>00091 m_output->ref(); <a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="comment">// recreate properties</span> <a name="l00094"></a>00094 m_interpreter->globalObject().put(exec, <span class="stringliteral">"document"</span>, *m_document); <a name="l00095"></a>00095 m_interpreter->globalObject().put(exec, <span class="stringliteral">"view"</span>, *m_view); <a name="l00096"></a>00096 <span class="comment">// create new properties</span> <a name="l00097"></a>00097 m_interpreter->globalObject().put(exec, <span class="stringliteral">"output"</span>, KJS::Object(m_output)); <a name="l00098"></a>00098 <span class="comment">// add convenience shortcuts</span> <a name="l00099"></a>00099 m_interpreter->globalObject().put(exec, <span class="stringliteral">"d"</span>, *m_document); <a name="l00100"></a>00100 m_interpreter->globalObject().put(exec, <span class="stringliteral">"v"</span>, *m_view); <a name="l00101"></a>00101 m_interpreter->globalObject().put(exec, <span class="stringliteral">"out"</span>, KJS::Object(m_output)); <a name="l00102"></a>00102 m_interpreter->globalObject().put(exec, <span class="stringliteral">"o"</span>, KJS::Object(m_output)); <a name="l00103"></a>00103 } <a name="l00104"></a>00104 <a name="l00105"></a>00105 TestJScriptEnv::~TestJScriptEnv() { <a name="l00106"></a>00106 m_output->deref(); <a name="l00107"></a>00107 } <a name="l00108"></a>00108 <a name="l00109"></a>00109 <span class="comment">//END TestJScriptEnv</span> <a name="l00110"></a>00110 <a name="l00111"></a>00111 <span class="comment">//BEGIN KateViewObject</span> <a name="l00112"></a>00112 <a name="l00113"></a>00113 KateViewObject::KateViewObject(ExecState *exec, KateView *v, ObjectImp *fallback) <a name="l00114"></a>00114 : view(v), fallback(fallback) <a name="l00115"></a>00115 { <a name="l00116"></a>00116 <span class="comment">// put a function</span> <a name="l00117"></a>00117 <span class="preprocessor">#define PUT_FUNC(name, enumval) \</span> <a name="l00118"></a>00118 <span class="preprocessor"> putDirect(#name, new KateViewFunction(exec,v,KateViewFunction::enumval,1), DontEnum)</span> <a name="l00119"></a>00119 <span class="preprocessor"></span> fallback->ref(); <a name="l00120"></a>00120 <a name="l00121"></a>00121 PUT_FUNC(keyReturn, KeyReturn); <a name="l00122"></a>00122 PUT_FUNC(enter, KeyReturn); <a name="l00123"></a>00123 PUT_FUNC(type, Type); <a name="l00124"></a>00124 PUT_FUNC(keyDelete, KeyDelete); <a name="l00125"></a>00125 PUT_FUNC(deleteWordRight, DeleteWordRight); <a name="l00126"></a>00126 PUT_FUNC(transpose, Transpose); <a name="l00127"></a>00127 PUT_FUNC(cursorLeft, CursorLeft); <a name="l00128"></a>00128 PUT_FUNC(cursorPrev, CursorLeft); <a name="l00129"></a>00129 PUT_FUNC(left, CursorLeft); <a name="l00130"></a>00130 PUT_FUNC(prev, CursorLeft); <a name="l00131"></a>00131 PUT_FUNC(shiftCursorLeft, ShiftCursorLeft); <a name="l00132"></a>00132 PUT_FUNC(shiftCursorPrev, ShiftCursorLeft); <a name="l00133"></a>00133 PUT_FUNC(shiftLeft, ShiftCursorLeft); <a name="l00134"></a>00134 PUT_FUNC(shiftPrev, ShiftCursorLeft); <a name="l00135"></a>00135 PUT_FUNC(cursorRight, CursorRight); <a name="l00136"></a>00136 PUT_FUNC(cursorNext, CursorRight); <a name="l00137"></a>00137 PUT_FUNC(right, CursorRight); <a name="l00138"></a>00138 PUT_FUNC(next, CursorRight); <a name="l00139"></a>00139 PUT_FUNC(shiftCursorRight, ShiftCursorRight); <a name="l00140"></a>00140 PUT_FUNC(shiftCursorNext, ShiftCursorRight); <a name="l00141"></a>00141 PUT_FUNC(shiftRight, ShiftCursorRight); <a name="l00142"></a>00142 PUT_FUNC(shiftNext, ShiftCursorRight); <a name="l00143"></a>00143 PUT_FUNC(wordLeft, WordLeft); <a name="l00144"></a>00144 PUT_FUNC(wordPrev, WordLeft); <a name="l00145"></a>00145 PUT_FUNC(shiftWordLeft, ShiftWordLeft); <a name="l00146"></a>00146 PUT_FUNC(shiftWordPrev, ShiftWordLeft); <a name="l00147"></a>00147 PUT_FUNC(wordRight, WordRight); <a name="l00148"></a>00148 PUT_FUNC(wordNext, WordRight); <a name="l00149"></a>00149 PUT_FUNC(shiftWordRight, ShiftWordRight); <a name="l00150"></a>00150 PUT_FUNC(shiftWordNext, ShiftWordRight); <a name="l00151"></a>00151 PUT_FUNC(home, Home); <a name="l00152"></a>00152 PUT_FUNC(shiftHome, ShiftHome); <a name="l00153"></a>00153 PUT_FUNC(end, End); <a name="l00154"></a>00154 PUT_FUNC(shiftEnd, ShiftEnd); <a name="l00155"></a>00155 PUT_FUNC(up, Up); <a name="l00156"></a>00156 PUT_FUNC(shiftUp, ShiftUp); <a name="l00157"></a>00157 PUT_FUNC(down, Down); <a name="l00158"></a>00158 PUT_FUNC(shiftDown, ShiftDown); <a name="l00159"></a>00159 PUT_FUNC(scrollUp, ScrollUp); <a name="l00160"></a>00160 PUT_FUNC(scrollDown, ScrollDown); <a name="l00161"></a>00161 PUT_FUNC(topOfView, TopOfView); <a name="l00162"></a>00162 PUT_FUNC(shiftTopOfView, ShiftTopOfView); <a name="l00163"></a>00163 PUT_FUNC(bottomOfView, BottomOfView); <a name="l00164"></a>00164 PUT_FUNC(shiftBottomOfView, ShiftBottomOfView); <a name="l00165"></a>00165 PUT_FUNC(pageUp, PageUp); <a name="l00166"></a>00166 PUT_FUNC(shiftPageUp, ShiftPageUp); <a name="l00167"></a>00167 PUT_FUNC(pageDown, PageDown); <a name="l00168"></a>00168 PUT_FUNC(shiftPageDown, ShiftPageDown); <a name="l00169"></a>00169 PUT_FUNC(top, Top); <a name="l00170"></a>00170 PUT_FUNC(shiftTop, ShiftTop); <a name="l00171"></a>00171 PUT_FUNC(bottom, Bottom); <a name="l00172"></a>00172 PUT_FUNC(shiftBottom, ShiftBottom); <a name="l00173"></a>00173 PUT_FUNC(toMatchingBracket, ToMatchingBracket); <a name="l00174"></a>00174 PUT_FUNC(shiftToMatchingBracket, ShiftToMatchingBracket); <a name="l00175"></a>00175 <span class="preprocessor">#undef PUT_FUNC</span> <a name="l00176"></a>00176 <span class="preprocessor"></span>} <a name="l00177"></a>00177 <a name="l00178"></a>00178 KateViewObject::~KateViewObject() <a name="l00179"></a>00179 { <a name="l00180"></a>00180 fallback->deref(); <a name="l00181"></a>00181 } <a name="l00182"></a>00182 <a name="l00183"></a>00183 <span class="keyword">const</span> ClassInfo *KateViewObject::classInfo()<span class="keyword"> const </span>{ <a name="l00184"></a>00184 <span class="comment">// evil hack II: disguise as fallback, otherwise we can't fall back</span> <a name="l00185"></a>00185 <span class="keywordflow">return</span> fallback->classInfo(); <a name="l00186"></a>00186 } <a name="l00187"></a>00187 <a name="l00188"></a>00188 Value KateViewObject::get(ExecState *exec, <span class="keyword">const</span> Identifier &propertyName)<span class="keyword"> const</span> <a name="l00189"></a>00189 <span class="keyword"></span>{ <a name="l00190"></a>00190 ValueImp *val = getDirect(propertyName); <a name="l00191"></a>00191 <span class="keywordflow">if</span> (val) <a name="l00192"></a>00192 <span class="keywordflow">return</span> Value(val); <a name="l00193"></a>00193 <a name="l00194"></a>00194 <span class="keywordflow">return</span> fallback->get(exec, propertyName); <a name="l00195"></a>00195 } <a name="l00196"></a>00196 <a name="l00197"></a>00197 <span class="comment">//END KateViewObject</span> <a name="l00198"></a>00198 <a name="l00199"></a>00199 <span class="comment">//BEGIN KateViewFunction</span> <a name="l00200"></a>00200 <a name="l00201"></a>00201 KateViewFunction::KateViewFunction(ExecState *<span class="comment">/*exec*/</span>, KateView *v, <span class="keywordtype">int</span> _id, <span class="keywordtype">int</span> length) <a name="l00202"></a>00202 { <a name="l00203"></a>00203 m_view = v; <a name="l00204"></a>00204 <span class="keywordtype">id</span> = _id; <a name="l00205"></a>00205 putDirect(<span class="stringliteral">"length"</span>,length); <a name="l00206"></a>00206 } <a name="l00207"></a>00207 <a name="l00208"></a>00208 <span class="keywordtype">bool</span> KateViewFunction::implementsCall()<span class="keyword"> const</span> <a name="l00209"></a>00209 <span class="keyword"></span>{ <a name="l00210"></a>00210 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00211"></a>00211 } <a name="l00212"></a>00212 <a name="l00213"></a>00213 Value KateViewFunction::call(ExecState *exec, Object &<span class="comment">/*thisObj*/</span>, <span class="keyword">const</span> List &args) <a name="l00214"></a>00214 { <a name="l00215"></a>00215 <span class="comment">// calls a function repeatedly as specified by its first parameter (once</span> <a name="l00216"></a>00216 <span class="comment">// if not specified).</span> <a name="l00217"></a>00217 <span class="preprocessor">#define REP_CALL(enumval, func) \</span> <a name="l00218"></a>00218 <span class="preprocessor"> case enumval: {\</span> <a name="l00219"></a>00219 <span class="preprocessor"> int cnt = 1;\</span> <a name="l00220"></a>00220 <span class="preprocessor"> if (args.size() > 0) cnt = args[0].toInt32(exec);\</span> <a name="l00221"></a>00221 <span class="preprocessor"> while (cnt-- > 0) { m_view->func(); }\</span> <a name="l00222"></a>00222 <span class="preprocessor"> return Undefined();\</span> <a name="l00223"></a>00223 <span class="preprocessor"> }</span> <a name="l00224"></a>00224 <span class="preprocessor"></span> <span class="keywordflow">switch</span> (<span class="keywordtype">id</span>) { <a name="l00225"></a>00225 REP_CALL(KeyReturn, keyReturn); <a name="l00226"></a>00226 REP_CALL(KeyDelete, keyDelete); <a name="l00227"></a>00227 REP_CALL(DeleteWordRight, deleteWordRight); <a name="l00228"></a>00228 REP_CALL(Transpose, transpose); <a name="l00229"></a>00229 REP_CALL(CursorLeft, cursorLeft); <a name="l00230"></a>00230 REP_CALL(ShiftCursorLeft, shiftCursorLeft); <a name="l00231"></a>00231 REP_CALL(CursorRight, cursorRight); <a name="l00232"></a>00232 REP_CALL(ShiftCursorRight, shiftCursorRight); <a name="l00233"></a>00233 REP_CALL(WordLeft, wordLeft); <a name="l00234"></a>00234 REP_CALL(ShiftWordLeft, shiftWordLeft); <a name="l00235"></a>00235 REP_CALL(WordRight, wordRight); <a name="l00236"></a>00236 REP_CALL(ShiftWordRight, shiftWordRight); <a name="l00237"></a>00237 REP_CALL(Home, home); <a name="l00238"></a>00238 REP_CALL(ShiftHome, shiftHome); <a name="l00239"></a>00239 REP_CALL(End, end); <a name="l00240"></a>00240 REP_CALL(ShiftEnd, shiftEnd); <a name="l00241"></a>00241 REP_CALL(Up, up); <a name="l00242"></a>00242 REP_CALL(ShiftUp, shiftUp); <a name="l00243"></a>00243 REP_CALL(Down, down); <a name="l00244"></a>00244 REP_CALL(ShiftDown, shiftDown); <a name="l00245"></a>00245 REP_CALL(ScrollUp, scrollUp); <a name="l00246"></a>00246 REP_CALL(ScrollDown, scrollDown); <a name="l00247"></a>00247 REP_CALL(TopOfView, topOfView); <a name="l00248"></a>00248 REP_CALL(ShiftTopOfView, shiftTopOfView); <a name="l00249"></a>00249 REP_CALL(BottomOfView, bottomOfView); <a name="l00250"></a>00250 REP_CALL(ShiftBottomOfView, shiftBottomOfView); <a name="l00251"></a>00251 REP_CALL(PageUp, pageUp); <a name="l00252"></a>00252 REP_CALL(ShiftPageUp, shiftPageUp); <a name="l00253"></a>00253 REP_CALL(PageDown, pageDown); <a name="l00254"></a>00254 REP_CALL(ShiftPageDown, shiftPageDown); <a name="l00255"></a>00255 REP_CALL(Top, top); <a name="l00256"></a>00256 REP_CALL(ShiftTop, shiftTop); <a name="l00257"></a>00257 REP_CALL(Bottom, bottom); <a name="l00258"></a>00258 REP_CALL(ShiftBottom, shiftBottom); <a name="l00259"></a>00259 REP_CALL(ToMatchingBracket, toMatchingBracket); <a name="l00260"></a>00260 REP_CALL(ShiftToMatchingBracket, shiftToMatchingBracket); <a name="l00261"></a>00261 <span class="keywordflow">case</span> Type: { <a name="l00262"></a>00262 UString str = args[0].toString(exec); <a name="l00263"></a>00263 <a class="codeRef" href="qstring.html">QString</a> res = str.qstring(); <a name="l00264"></a>00264 <span class="keywordflow">return</span> Boolean(m_view->doc()->typeChars(m_view, res)); <a name="l00265"></a>00265 } <a name="l00266"></a>00266 } <a name="l00267"></a>00267 <a name="l00268"></a>00268 <span class="keywordflow">return</span> Undefined(); <a name="l00269"></a>00269 <span class="preprocessor">#undef REP_CALL</span> <a name="l00270"></a>00270 <span class="preprocessor"></span>} <a name="l00271"></a>00271 <a name="l00272"></a>00272 <span class="comment">//END KateViewFunction</span> <a name="l00273"></a>00273 <a name="l00274"></a>00274 <span class="comment">//BEGIN OutputObject</span> <a name="l00275"></a>00275 <a name="l00276"></a>00276 OutputObject::OutputObject(KJS::ExecState *exec, KateDocument *d, KateView *v) : doc(d), view(v), changed(0), outstr(0) { <a name="l00277"></a>00277 putDirect(<span class="stringliteral">"write"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::Write,-1), DontEnum); <a name="l00278"></a>00278 putDirect(<span class="stringliteral">"print"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::Write,-1), DontEnum); <a name="l00279"></a>00279 putDirect(<span class="stringliteral">"writeln"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::Writeln,-1), DontEnum); <a name="l00280"></a>00280 putDirect(<span class="stringliteral">"println"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::Writeln,-1), DontEnum); <a name="l00281"></a>00281 putDirect(<span class="stringliteral">"writeLn"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::Writeln,-1), DontEnum); <a name="l00282"></a>00282 putDirect(<span class="stringliteral">"printLn"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::Writeln,-1), DontEnum); <a name="l00283"></a>00283 <a name="l00284"></a>00284 putDirect(<span class="stringliteral">"writeCursorPosition"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::WriteCursorPosition,-1), DontEnum); <a name="l00285"></a>00285 putDirect(<span class="stringliteral">"cursorPosition"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::WriteCursorPosition,-1), DontEnum); <a name="l00286"></a>00286 putDirect(<span class="stringliteral">"pos"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::WriteCursorPosition,-1), DontEnum); <a name="l00287"></a>00287 putDirect(<span class="stringliteral">"writeCursorPositionln"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::WriteCursorPositionln,-1), DontEnum); <a name="l00288"></a>00288 putDirect(<span class="stringliteral">"cursorPositionln"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::WriteCursorPositionln,-1), DontEnum); <a name="l00289"></a>00289 putDirect(<span class="stringliteral">"posln"</span>, <span class="keyword">new</span> <a class="code" href="classOutputFunction.html" title="Customizing output to result-files.">OutputFunction</a>(exec,<span class="keyword">this</span>,OutputFunction::WriteCursorPositionln,-1), DontEnum); <a name="l00290"></a>00290 <a name="l00291"></a>00291 } <a name="l00292"></a>00292 <a name="l00293"></a>00293 OutputObject::~OutputObject() { <a name="l00294"></a>00294 } <a name="l00295"></a>00295 <a name="l00296"></a>00296 KJS::UString OutputObject::className()<span class="keyword"> const </span>{ <a name="l00297"></a>00297 <span class="keywordflow">return</span> UString(<span class="stringliteral">"OutputObject"</span>); <a name="l00298"></a>00298 } <a name="l00299"></a>00299 <a name="l00300"></a>00300 <span class="comment">//END OutputObject</span> <a name="l00301"></a>00301 <a name="l00302"></a>00302 <span class="comment">//BEGIN OutputFunction</span> <a name="l00303"></a>00303 <a name="l00304"></a>00304 OutputFunction::OutputFunction(KJS::ExecState *exec, <a class="code" href="classOutputObject.html" title="Customizing output to result-files.">OutputObject</a> *output, <span class="keywordtype">int</span> _id, <span class="keywordtype">int</span> length) <a name="l00305"></a>00305 : o(output) <a name="l00306"></a>00306 { <a name="l00307"></a>00307 <span class="keywordtype">id</span> = _id; <a name="l00308"></a>00308 <span class="keywordflow">if</span> (length >= 0) <a name="l00309"></a>00309 putDirect(<span class="stringliteral">"length"</span>,length); <a name="l00310"></a>00310 } <a name="l00311"></a>00311 <a name="l00312"></a>00312 <span class="keywordtype">bool</span> OutputFunction::implementsCall()<span class="keyword"> const</span> <a name="l00313"></a>00313 <span class="keyword"></span>{ <a name="l00314"></a>00314 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00315"></a>00315 } <a name="l00316"></a>00316 <a name="l00317"></a>00317 KJS::Value OutputFunction::call(KJS::ExecState *exec, KJS::Object &thisObj, <span class="keyword">const</span> KJS::List &args) <a name="l00318"></a>00318 { <a name="l00319"></a>00319 <span class="keywordflow">if</span> (!*o->changed) *o->outstr = <a class="codeRef" href="qstring.html">QString</a>(); <a name="l00320"></a>00320 <a name="l00321"></a>00321 <span class="keywordflow">switch</span> (<span class="keywordtype">id</span>) { <a name="l00322"></a>00322 <span class="keywordflow">case</span> Write: <a name="l00323"></a>00323 <span class="keywordflow">case</span> Writeln: { <a name="l00324"></a>00324 <span class="comment">// Gather all parameters and concatenate to string</span> <a name="l00325"></a>00325 <a class="codeRef" href="qstring.html">QString</a> res; <a name="l00326"></a>00326 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < args.size(); i++) { <a name="l00327"></a>00327 res += args[i].toString(exec).qstring(); <a name="l00328"></a>00328 } <a name="l00329"></a>00329 <a name="l00330"></a>00330 <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == Writeln) <a name="l00331"></a>00331 res += <span class="stringliteral">"\n"</span>; <a name="l00332"></a>00332 <a name="l00333"></a>00333 *o->outstr += res; <a name="l00334"></a>00334 <span class="keywordflow">break</span>; <a name="l00335"></a>00335 } <a name="l00336"></a>00336 <span class="keywordflow">case</span> WriteCursorPositionln: <a name="l00337"></a>00337 <span class="keywordflow">case</span> WriteCursorPosition: { <a name="l00338"></a>00338 <span class="comment">// Gather all parameters and concatenate to string</span> <a name="l00339"></a>00339 <a class="codeRef" href="qstring.html">QString</a> res; <a name="l00340"></a>00340 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < args.size(); i++) { <a name="l00341"></a>00341 res += args[i].toString(exec).qstring(); <a name="l00342"></a>00342 } <a name="l00343"></a>00343 <a name="l00344"></a>00344 <span class="comment">// Append cursor position</span> <a name="l00345"></a>00345 uint l, c; <a name="l00346"></a>00346 o->view->cursorPosition(&l, &c); <a name="l00347"></a>00347 res += <span class="stringliteral">"("</span> + <a class="codeRef" href="qstring.html#number">QString::number</a>(l) + <span class="stringliteral">","</span> + <a class="codeRef" href="qstring.html#number">QString::number</a>(c) + <span class="stringliteral">")"</span>; <a name="l00348"></a>00348 <a name="l00349"></a>00349 <span class="keywordflow">if</span> (<span class="keywordtype">id</span> == WriteCursorPositionln) <a name="l00350"></a>00350 res += <span class="stringliteral">"\n"</span>; <a name="l00351"></a>00351 <a name="l00352"></a>00352 *o->outstr += res; <a name="l00353"></a>00353 <span class="keywordflow">break</span>; <a name="l00354"></a>00354 } <a name="l00355"></a>00355 } <a name="l00356"></a>00356 <a name="l00357"></a>00357 *o->changed = <span class="keyword">true</span>; <a name="l00358"></a>00358 <span class="keywordflow">return</span> Undefined(); <a name="l00359"></a>00359 } <a name="l00360"></a>00360 <a name="l00361"></a>00361 <span class="comment">//END OutputFunction</span> <a name="l00362"></a>00362 <a name="l00363"></a>00363 <span class="comment">// -------------------------------------------------------------------------</span> <a name="l00364"></a>00364 <a name="l00365"></a>00365 <span class="keyword">const</span> <span class="keywordtype">char</span> failureSnapshotPrefix[] = <span class="stringliteral">"testkateregressionrc-FS."</span>; <a name="l00366"></a>00366 <a name="l00367"></a>00367 <span class="keyword">static</span> <a class="codeRef" href="qstring.html">QString</a> findMostRecentFailureSnapshot() { <a name="l00368"></a>00368 <a class="codeRef" href="qdir.html">QDir</a> dir(kapp->dirs()->saveLocation(<span class="stringliteral">"config"</span>), <a name="l00369"></a>00369 <a class="codeRef" href="qstring.html">QString</a>(failureSnapshotPrefix)+<span class="stringliteral">"*"</span>, <a name="l00370"></a>00370 QDir::Time, QDir::Files); <a name="l00371"></a>00371 <span class="keywordflow">return</span> dir[0].mid(<span class="keyword">sizeof</span> failureSnapshotPrefix - 1); <a name="l00372"></a>00372 } <a name="l00373"></a>00373 <a name="l00374"></a>00374 <span class="keyword">static</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/structKCmdLineOptions.html">KCmdLineOptions</a> options[] = <a name="l00375"></a>00375 { <a name="l00376"></a>00376 { <span class="stringliteral">"b"</span>, 0, 0 }, <a name="l00377"></a>00377 { <span class="stringliteral">"base <base_dir>"</span>, <span class="stringliteral">"Directory containing tests, basedir and output directories."</span>, 0}, <a name="l00378"></a>00378 { <span class="stringliteral">"cmp-failures <snapshot>"</span>, <span class="stringliteral">"Compare failures of this testrun against snapshot <snapshot>. Defaults to the most recently captured failure snapshot or none if none exists."</span>, 0 }, <a name="l00379"></a>00379 { <span class="stringliteral">"d"</span>, 0, 0 }, <a name="l00380"></a>00380 { <span class="stringliteral">"debug"</span>, <span class="stringliteral">"Do not supress debug output"</span>, 0}, <a name="l00381"></a>00381 { <span class="stringliteral">"g"</span>, 0, 0 } , <a name="l00382"></a>00382 { <span class="stringliteral">"genoutput"</span>, <span class="stringliteral">"Regenerate baseline (instead of checking)"</span>, 0 } , <a name="l00383"></a>00383 { <span class="stringliteral">"keep-output"</span>, <span class="stringliteral">"Keep output files even on success"</span>, 0 }, <a name="l00384"></a>00384 { <span class="stringliteral">"save-failures <snapshot>"</span>, <span class="stringliteral">"Save failures of this testrun as failure snapshot <snapshot>"</span>, 0 }, <a name="l00385"></a>00385 { <span class="stringliteral">"s"</span>, 0, 0 } , <a name="l00386"></a>00386 { <span class="stringliteral">"show"</span>, <span class="stringliteral">"Show the window while running tests"</span>, 0 } , <a name="l00387"></a>00387 { <span class="stringliteral">"t"</span>, 0, 0 } , <a name="l00388"></a>00388 { <span class="stringliteral">"test <filename>"</span>, <span class="stringliteral">"Only run a single test. Multiple options allowed."</span>, 0 } , <a name="l00389"></a>00389 { <span class="stringliteral">"o"</span>, 0, 0 }, <a name="l00390"></a>00390 { <span class="stringliteral">"output <directory>"</span>, <span class="stringliteral">"Put output in <directory> instead of <base_dir>/output"</span>, 0 } , <a name="l00391"></a>00391 { <span class="stringliteral">"+[base_dir]"</span>, <span class="stringliteral">"Directory containing tests,basedir and output directories. Only regarded if -b is not specified."</span>, 0 } , <a name="l00392"></a>00392 { <span class="stringliteral">"+[testcases]"</span>, <span class="stringliteral">"Relative path to testcase, or directory of testcases to be run (equivalent to -t)."</span>, 0 } , <a name="l00393"></a>00393 KCmdLineLastOption <a name="l00394"></a>00394 }; <a name="l00395"></a>00395 <a name="l00396"></a>00396 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]) <a name="l00397"></a>00397 { <a name="l00398"></a>00398 <span class="comment">// forget about any settings</span> <a name="l00399"></a>00399 passwd* pw = getpwuid( getuid() ); <a name="l00400"></a>00400 <span class="keywordflow">if</span> (!pw) { <a name="l00401"></a>00401 fprintf(stderr, <span class="stringliteral">"dang, I don't even know who I am.\n"</span>); <a name="l00402"></a>00402 exit(1); <a name="l00403"></a>00403 } <a name="l00404"></a>00404 <a name="l00405"></a>00405 <a class="codeRef" href="qstring.html">QString</a> kh(<span class="stringliteral">"/var/tmp/%1_kate_non_existent"</span>); <a name="l00406"></a>00406 kh = kh.arg( pw->pw_name ); <a name="l00407"></a>00407 setenv( <span class="stringliteral">"KDEHOME"</span>, kh.latin1(), 1 ); <a name="l00408"></a>00408 setenv( <span class="stringliteral">"LC_ALL"</span>, <span class="stringliteral">"C"</span>, 1 ); <a name="l00409"></a>00409 setenv( <span class="stringliteral">"LANG"</span>, <span class="stringliteral">"C"</span>, 1 ); <a name="l00410"></a>00410 <a name="l00411"></a>00411 <span class="comment">// signal( SIGALRM, signal_handler );</span> <a name="l00412"></a>00412 <a name="l00413"></a>00413 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a6fc0ecc5385a924cdbe0e2e668e52517">KCmdLineArgs::init</a>(argc, argv, <span class="stringliteral">"testregression"</span>, <span class="stringliteral">"TestRegression"</span>, <a name="l00414"></a>00414 <span class="stringliteral">"Regression tester for kate"</span>, <span class="stringliteral">"1.0"</span>); <a name="l00415"></a>00415 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#aa27bb279d3b0f958dcc249dd42b90ce1">KCmdLineArgs::addCmdLineOptions</a>(options); <a name="l00416"></a>00416 <a name="l00417"></a>00417 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html">KCmdLineArgs</a> *args = <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#acd1cd75c0ac04930b0acec605a42cc54">KCmdLineArgs::parsedArgs</a>( ); <a name="l00418"></a>00418 <a name="l00419"></a>00419 <a class="codeRef" href="qcstring.html">QCString</a> baseDir = args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#ac82aded6dcc1f9446c4c578d7116bc52">getOption</a>(<span class="stringliteral">"base"</span>); <a name="l00420"></a>00420 <a class="codeRef" href="qcstring.html">QCString</a> baseDirConfigFile(::getenv(<span class="stringliteral">"HOME"</span>) + <a class="codeRef" href="qcstring.html">QCString</a>(BASE_DIR_CONFIG)); <a name="l00421"></a>00421 { <a name="l00422"></a>00422 <a class="codeRef" href="qfile.html">QFile</a> baseDirConfig(baseDirConfigFile); <a name="l00423"></a>00423 <span class="keywordflow">if</span> (baseDirConfig.open(IO_ReadOnly)) { <a name="l00424"></a>00424 <a class="codeRef" href="qtextstream.html">QTextStream</a> bds(&baseDirConfig); <a name="l00425"></a>00425 baseDir = bds.readLine().latin1(); <a name="l00426"></a>00426 } <a name="l00427"></a>00427 } <a name="l00428"></a>00428 <a name="l00429"></a>00429 <span class="keywordflow">if</span> ( args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a9f1b8ca6c31221cafeaa138ee5188895">count</a>() < 1 && baseDir.<a class="codeRef" href="qcstring.html#isEmpty">isEmpty</a>() ) { <a name="l00430"></a>00430 printf(<span class="stringliteral">"For regression testing, make sure to have checked out the kate regression\n"</span> <a name="l00431"></a>00431 <span class="stringliteral">"testsuite from svn:\n"</span> <a name="l00432"></a>00432 <span class="stringliteral">"\tsvn co \"https://<user>@svn.kde.org:/home/kde/trunk/tests/katetests/regression\"\n"</span> <a name="l00433"></a>00433 <span class="stringliteral">"Remember the root path into which you checked out the testsuite.\n"</span> <a name="l00434"></a>00434 <span class="stringliteral">"\n"</span>); <a name="l00435"></a>00435 printf(<span class="stringliteral">"%s needs the root path of the kate regression\n"</span> <a name="l00436"></a>00436 <span class="stringliteral">"testsuite to function properly\n"</span> <a name="l00437"></a>00437 <span class="stringliteral">"By default, the root path is looked up in the file\n"</span> <a name="l00438"></a>00438 <span class="stringliteral">"\t%s\n"</span> <a name="l00439"></a>00439 <span class="stringliteral">"If it doesn't exist yet, create it by invoking\n"</span> <a name="l00440"></a>00440 <span class="stringliteral">"\techo \"<root-path>\" > %s\n"</span> <a name="l00441"></a>00441 <span class="stringliteral">"You may override the location by specifying the root explicitly on the\n"</span> <a name="l00442"></a>00442 <span class="stringliteral">"command line with option -b\n"</span> <a name="l00443"></a>00443 <span class="stringliteral">""</span>, <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#ade69c956977ab5e1879f65c6fba8485a">KCmdLineArgs::appName</a>(), <a name="l00444"></a>00444 (<span class="keyword">const</span> <span class="keywordtype">char</span> *)baseDirConfigFile, <a name="l00445"></a>00445 (<span class="keyword">const</span> <span class="keywordtype">char</span> *)baseDirConfigFile); <a name="l00446"></a>00446 ::exit( 1 ); <a name="l00447"></a>00447 } <a name="l00448"></a>00448 <a name="l00449"></a>00449 <span class="keywordtype">int</span> testcase_index = 0; <a name="l00450"></a>00450 <span class="keywordflow">if</span> (baseDir.<a class="codeRef" href="qcstring.html#isEmpty">isEmpty</a>()) baseDir = args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#ae3c2372b95f7c25d4a9b4cb507f31014">arg</a>(testcase_index++); <a name="l00451"></a>00451 <a name="l00452"></a>00452 <a class="codeRef" href="qfileinfo.html">QFileInfo</a> bdInfo(baseDir); <a name="l00453"></a>00453 baseDir = <a class="codeRef" href="qfile.html#encodeName">QFile::encodeName</a>(bdInfo.absFilePath()); <a name="l00454"></a>00454 <a name="l00455"></a>00455 <span class="keyword">const</span> <span class="keywordtype">char</span> *subdirs[] = {<span class="stringliteral">"tests"</span>, <span class="stringliteral">"baseline"</span>, <span class="stringliteral">"output"</span>, <span class="stringliteral">"resources"</span>}; <a name="l00456"></a>00456 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < 2; i++ ) { <a name="l00457"></a>00457 <a class="codeRef" href="qfileinfo.html">QFileInfo</a> sourceDir(<a class="codeRef" href="qfile.html#encodeName">QFile::encodeName</a>( baseDir ) + <span class="stringliteral">"/"</span> + subdirs[i]); <a name="l00458"></a>00458 <span class="keywordflow">if</span> ( !sourceDir.exists() || !sourceDir.isDir() ) { <a name="l00459"></a>00459 fprintf(stderr,<span class="stringliteral">"ERROR: Source directory \"%s/%s\": no such directory.\n"</span>, (<span class="keyword">const</span> <span class="keywordtype">char</span> *)baseDir, subdirs[i]); <a name="l00460"></a>00460 exit(1); <a name="l00461"></a>00461 } <a name="l00462"></a>00462 } <a name="l00463"></a>00463 <a name="l00464"></a>00464 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKApplication.html">KApplication</a> a; <a name="l00465"></a>00465 a.<a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKApplication.html#ad7fb5d92aa28302d2be1c6b97c49bc39">disableAutoDcopRegistration</a>(); <a name="l00466"></a>00466 a.<a class="codeRef" href="qapplication.html#setStyle">setStyle</a>(<span class="stringliteral">"windows"</span>); <a name="l00467"></a>00467 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKSimpleConfig.html">KSimpleConfig</a> cfg( <span class="stringliteral">"testkateregressionrc"</span> ); <a name="l00468"></a>00468 cfg.setGroup(<span class="stringliteral">"Kate Document Defaults"</span>); <a name="l00469"></a>00469 cfg.writeEntry(<span class="stringliteral">"Basic Config Flags"</span>, <a name="l00470"></a>00470 KateDocumentConfig::cfBackspaceIndents <a name="l00471"></a>00471 <span class="comment">// | KateDocumentConfig::cfWordWrap</span> <a name="l00472"></a>00472 <span class="comment">// | KateDocumentConfig::cfRemoveSpaces</span> <a name="l00473"></a>00473 | KateDocumentConfig::cfWrapCursor <a name="l00474"></a>00474 <span class="comment">// | KateDocumentConfig::cfAutoBrackets</span> <a name="l00475"></a>00475 <span class="comment">// | KateDocumentConfig::cfTabIndentsMode</span> <a name="l00476"></a>00476 <span class="comment">// | KateDocumentConfig::cfOvr</span> <a name="l00477"></a>00477 | KateDocumentConfig::cfKeepIndentProfile <a name="l00478"></a>00478 | KateDocumentConfig::cfKeepExtraSpaces <a name="l00479"></a>00479 | KateDocumentConfig::cfTabIndents <a name="l00480"></a>00480 | KateDocumentConfig::cfShowTabs <a name="l00481"></a>00481 | KateDocumentConfig::cfSpaceIndent <a name="l00482"></a>00482 | KateDocumentConfig::cfSmartHome <a name="l00483"></a>00483 | KateDocumentConfig::cfTabInsertsTab <a name="l00484"></a>00484 <span class="comment">// | KateDocumentConfig::cfReplaceTabsDyn</span> <a name="l00485"></a>00485 <span class="comment">// | KateDocumentConfig::cfRemoveTrailingDyn</span> <a name="l00486"></a>00486 | KateDocumentConfig::cfDoxygenAutoTyping <a name="l00487"></a>00487 <span class="comment">// | KateDocumentConfig::cfMixedIndent</span> <a name="l00488"></a>00488 | KateDocumentConfig::cfIndentPastedText <a name="l00489"></a>00489 ); <a name="l00490"></a>00490 cfg.sync(); <a name="l00491"></a>00491 <a name="l00492"></a>00492 <span class="keywordtype">int</span> rv = 1; <a name="l00493"></a>00493 <a name="l00494"></a>00494 { <a name="l00495"></a>00495 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKSimpleConfig.html">KSimpleConfig</a> dc( <span class="stringliteral">"kdebugrc"</span> ); <a name="l00496"></a>00496 <span class="comment">// FIXME adapt to kate</span> <a name="l00497"></a>00497 <span class="keyword">static</span> <span class="keywordtype">int</span> areas[] = { 1000, 13000, 13001, 13002, 13010, <a name="l00498"></a>00498 13020, 13025, 13030, 13033, 13035, <a name="l00499"></a>00499 13040, 13050, 13051, 7000, 7006, 170, <a name="l00500"></a>00500 171, 7101, 7002, 7019, 7027, 7014, <a name="l00501"></a>00501 7001, 7011, 6070, 6080, 6090, 0}; <a name="l00502"></a>00502 <span class="keywordtype">int</span> channel = args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a4ed1605753de66b1c1d33b43ae99303f">isSet</a>( <span class="stringliteral">"debug"</span> ) ? 2 : 4; <a name="l00503"></a>00503 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; areas[i]; ++i ) { <a name="l00504"></a>00504 dc.setGroup( <a class="codeRef" href="qstring.html#number">QString::number</a>( areas[i] ) ); <a name="l00505"></a>00505 dc.writeEntry( <span class="stringliteral">"InfoOutput"</span>, channel ); <a name="l00506"></a>00506 } <a name="l00507"></a>00507 dc.sync(); <a name="l00508"></a>00508 <a name="l00509"></a>00509 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/group__kdebug.html#ga8bd482a04ce3e9a2790cd91ee0a02b63">kdClearDebugConfig</a>(); <a name="l00510"></a>00510 } <a name="l00511"></a>00511 <a name="l00512"></a>00512 <span class="comment">// create widgets</span> <a name="l00513"></a>00513 KateFactory *fac = KateFactory::self(); <a name="l00514"></a>00514 <a class="codeRef" doxygen="kdeui.tag:../../kdeui/html/" href="../../kdeui/html/classKMainWindow.html">KMainWindow</a> *toplevel = <span class="keyword">new</span> <a class="codeRef" doxygen="kdeui.tag:../../kdeui/html/" href="../../kdeui/html/classKMainWindow.html">KMainWindow</a>(); <a name="l00515"></a>00515 KateDocument *part = <span class="keyword">new</span> KateDocument(<span class="comment">/*bSingleViewMode*/</span><span class="keyword">true</span>, <a name="l00516"></a>00516 <span class="comment">/*bBrowserView*/</span><span class="keyword">false</span>, <a name="l00517"></a>00517 <span class="comment">/*bReadOnly*/</span><span class="keyword">false</span>, <a name="l00518"></a>00518 <span class="comment">/*parentWidget*/</span>toplevel, <a name="l00519"></a>00519 <span class="comment">/*widgetName*/</span><span class="stringliteral">"testkate"</span>); <a name="l00520"></a>00520 part->readConfig(&cfg); <a name="l00521"></a>00521 <a name="l00522"></a>00522 toplevel-><a class="codeRef" href="qmainwindow.html#setCentralWidget">setCentralWidget</a>( part->widget() ); <a name="l00523"></a>00523 <a name="l00524"></a>00524 Q_ASSERT(part->config()->configFlags() & KateDocumentConfig::cfDoxygenAutoTyping); <a name="l00525"></a>00525 <a name="l00526"></a>00526 <span class="keywordtype">bool</span> visual = <span class="keyword">false</span>; <a name="l00527"></a>00527 <span class="keywordflow">if</span> (args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a4ed1605753de66b1c1d33b43ae99303f">isSet</a>(<span class="stringliteral">"show"</span>)) <a name="l00528"></a>00528 visual = <span class="keyword">true</span>; <a name="l00529"></a>00529 <a name="l00530"></a>00530 a.<a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKApplication.html#a4ca52b277f11f5b216e44b675ff70ee4">setTopWidget</a>(part->widget()); <a name="l00531"></a>00531 a.<a class="codeRef" href="qapplication.html#setMainWidget">setMainWidget</a>( toplevel ); <a name="l00532"></a>00532 <span class="keywordflow">if</span> ( visual ) <a name="l00533"></a>00533 toplevel-><a class="codeRef" doxygen="kdeui.tag:../../kdeui/html/" href="../../kdeui/html/classKMainWindow.html#a048cec06b43ea0e9afdb460040694117">show</a>(); <a name="l00534"></a>00534 <a name="l00535"></a>00535 <span class="comment">// we're not interested</span> <a name="l00536"></a>00536 toplevel-><a class="codeRef" doxygen="kdeui.tag:../../kdeui/html/" href="../../kdeui/html/classKMainWindow.html#a4cf634139ca0305c19d90390c9560e89">statusBar</a>()->hide(); <a name="l00537"></a>00537 <a name="l00538"></a>00538 <span class="keywordflow">if</span> (!getenv(<span class="stringliteral">"KDE_DEBUG"</span>)) { <a name="l00539"></a>00539 <span class="comment">// set ulimits</span> <a name="l00540"></a>00540 rlimit vmem_limit = { 256*1024*1024, RLIM_INFINITY }; <span class="comment">// 256Mb Memory should suffice</span> <a name="l00541"></a>00541 setrlimit(RLIMIT_AS, &vmem_limit); <a name="l00542"></a>00542 rlimit stack_limit = { 8*1024*1024, RLIM_INFINITY }; <span class="comment">// 8Mb Memory should suffice</span> <a name="l00543"></a>00543 setrlimit(RLIMIT_STACK, &stack_limit); <a name="l00544"></a>00544 } <a name="l00545"></a>00545 <a name="l00546"></a>00546 <span class="comment">// run the tests</span> <a name="l00547"></a>00547 RegressionTest *regressionTest = <span class="keyword">new</span> RegressionTest(part, <a name="l00548"></a>00548 &cfg, <a name="l00549"></a>00549 baseDir, <a name="l00550"></a>00550 args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#ac82aded6dcc1f9446c4c578d7116bc52">getOption</a>(<span class="stringliteral">"output"</span>), <a name="l00551"></a>00551 args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a4ed1605753de66b1c1d33b43ae99303f">isSet</a>(<span class="stringliteral">"genoutput"</span>)); <a name="l00552"></a>00552 <a class="codeRef" href="qobject.html#connect">QObject::connect</a>(part->browserExtension(), SIGNAL(openURLRequest(<span class="keyword">const</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKURL.html">KURL</a> &, <span class="keyword">const</span> <a class="codeRef" doxygen="kparts.tag:../../kparts/html/" href="../../kparts/html/structKParts_1_1URLArgs.html">KParts::URLArgs</a> &)), <a name="l00553"></a>00553 regressionTest, SLOT(slotOpenURL(<span class="keyword">const</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKURL.html">KURL</a>&, <span class="keyword">const</span> <a class="codeRef" doxygen="kparts.tag:../../kparts/html/" href="../../kparts/html/structKParts_1_1URLArgs.html">KParts::URLArgs</a> &))); <a name="l00554"></a>00554 <a class="codeRef" href="qobject.html#connect">QObject::connect</a>(part->browserExtension(), SIGNAL(resizeTopLevelWidget( <span class="keywordtype">int</span>, <span class="keywordtype">int</span> )), <a name="l00555"></a>00555 regressionTest, SLOT(resizeTopLevelWidget( <span class="keywordtype">int</span>, <span class="keywordtype">int</span> ))); <a name="l00556"></a>00556 <a name="l00557"></a>00557 regressionTest->m_keepOutput = args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a4ed1605753de66b1c1d33b43ae99303f">isSet</a>(<span class="stringliteral">"keep-output"</span>); <a name="l00558"></a>00558 regressionTest->m_showGui = args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a4ed1605753de66b1c1d33b43ae99303f">isSet</a>(<span class="stringliteral">"show"</span>); <a name="l00559"></a>00559 <a name="l00560"></a>00560 { <a name="l00561"></a>00561 <a class="codeRef" href="qstring.html">QString</a> failureSnapshot = args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#ac82aded6dcc1f9446c4c578d7116bc52">getOption</a>(<span class="stringliteral">"cmp-failures"</span>); <a name="l00562"></a>00562 <span class="keywordflow">if</span> (failureSnapshot.<a class="codeRef" href="qstring.html#isEmpty">isEmpty</a>()) <a name="l00563"></a>00563 failureSnapshot = findMostRecentFailureSnapshot(); <a name="l00564"></a>00564 <span class="keywordflow">if</span> (!failureSnapshot.<a class="codeRef" href="qstring.html#isEmpty">isEmpty</a>()) <a name="l00565"></a>00565 regressionTest->setFailureSnapshotConfig( <a name="l00566"></a>00566 <span class="keyword">new</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKSimpleConfig.html">KSimpleConfig</a>(failureSnapshotPrefix + failureSnapshot, <span class="keyword">true</span>), <a name="l00567"></a>00567 failureSnapshot); <a name="l00568"></a>00568 } <a name="l00569"></a>00569 <a name="l00570"></a>00570 <span class="keywordflow">if</span> (args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a4ed1605753de66b1c1d33b43ae99303f">isSet</a>(<span class="stringliteral">"save-failures"</span>)) { <a name="l00571"></a>00571 <a class="codeRef" href="qstring.html">QString</a> failureSaver = args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#ac82aded6dcc1f9446c4c578d7116bc52">getOption</a>(<span class="stringliteral">"save-failures"</span>); <a name="l00572"></a>00572 regressionTest->setFailureSnapshotSaver( <a name="l00573"></a>00573 <span class="keyword">new</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKSimpleConfig.html">KSimpleConfig</a>(failureSnapshotPrefix + failureSaver, <span class="keyword">false</span>), <a name="l00574"></a>00574 failureSaver); <a name="l00575"></a>00575 } <a name="l00576"></a>00576 <a name="l00577"></a>00577 <span class="keywordtype">bool</span> result = <span class="keyword">false</span>; <a name="l00578"></a>00578 QCStringList tests = args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#ae2d38b09a5729d15123f6a99ba22675a">getOptionList</a>(<span class="stringliteral">"test"</span>); <a name="l00579"></a>00579 <span class="comment">// merge testcases specified on command line</span> <a name="l00580"></a>00580 <span class="keywordflow">for</span> (; testcase_index < args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a9f1b8ca6c31221cafeaa138ee5188895">count</a>(); testcase_index++) <a name="l00581"></a>00581 tests << args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#ae3c2372b95f7c25d4a9b4cb507f31014">arg</a>(testcase_index); <a name="l00582"></a>00582 <span class="keywordflow">if</span> (tests.count() > 0) <a name="l00583"></a>00583 <span class="keywordflow">for</span> (<a class="codeRef" href="qvaluelistconstiterator.html">QValueListConstIterator<QCString></a> it = tests.begin(); it != tests.end(); ++it) { <a name="l00584"></a>00584 result = regressionTest->runTests(*it,<span class="keyword">true</span>); <a name="l00585"></a>00585 <span class="keywordflow">if</span> (!result) <span class="keywordflow">break</span>; <a name="l00586"></a>00586 } <a name="l00587"></a>00587 <span class="keywordflow">else</span> <a name="l00588"></a>00588 result = regressionTest->runTests(); <a name="l00589"></a>00589 <a name="l00590"></a>00590 <span class="keywordflow">if</span> (result) { <a name="l00591"></a>00591 <span class="keywordflow">if</span> (args-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKCmdLineArgs.html#a4ed1605753de66b1c1d33b43ae99303f">isSet</a>(<span class="stringliteral">"genoutput"</span>)) { <a name="l00592"></a>00592 printf(<span class="stringliteral">"\nOutput generation completed.\n"</span>); <a name="l00593"></a>00593 } <a name="l00594"></a>00594 <span class="keywordflow">else</span> { <a name="l00595"></a>00595 printf(<span class="stringliteral">"\nTests completed.\n"</span>); <a name="l00596"></a>00596 printf(<span class="stringliteral">"Total: %d\n"</span>, <a name="l00597"></a>00597 regressionTest->m_passes_work+ <a name="l00598"></a>00598 regressionTest->m_passes_fail+ <a name="l00599"></a>00599 regressionTest->m_failures_work+ <a name="l00600"></a>00600 regressionTest->m_failures_fail+ <a name="l00601"></a>00601 regressionTest->m_errors); <a name="l00602"></a>00602 printf(<span class="stringliteral">"Passes: %d"</span>,regressionTest->m_passes_work); <a name="l00603"></a>00603 <span class="keywordflow">if</span> ( regressionTest->m_passes_fail ) <a name="l00604"></a>00604 printf( <span class="stringliteral">" (%d unexpected passes)"</span>, regressionTest->m_passes_fail ); <a name="l00605"></a>00605 <span class="keywordflow">if</span> (regressionTest->m_passes_new) <a name="l00606"></a>00606 printf(<span class="stringliteral">" (%d new since %s)"</span>, regressionTest->m_passes_new, regressionTest->m_failureComp->group().latin1()); <a name="l00607"></a>00607 printf( <span class="stringliteral">"\n"</span> ); <a name="l00608"></a>00608 printf(<span class="stringliteral">"Failures: %d"</span>,regressionTest->m_failures_work); <a name="l00609"></a>00609 <span class="keywordflow">if</span> ( regressionTest->m_failures_fail ) <a name="l00610"></a>00610 printf( <span class="stringliteral">" (%d expected failures)"</span>, regressionTest->m_failures_fail ); <a name="l00611"></a>00611 <span class="keywordflow">if</span> ( regressionTest->m_failures_new ) <a name="l00612"></a>00612 printf(<span class="stringliteral">" (%d new since %s)"</span>, regressionTest->m_failures_new, regressionTest->m_failureComp->group().latin1()); <a name="l00613"></a>00613 printf( <span class="stringliteral">"\n"</span> ); <a name="l00614"></a>00614 <span class="keywordflow">if</span> ( regressionTest->m_errors ) <a name="l00615"></a>00615 printf(<span class="stringliteral">"Errors: %d\n"</span>,regressionTest->m_errors); <a name="l00616"></a>00616 <a name="l00617"></a>00617 <a class="codeRef" href="qfile.html">QFile</a> list( regressionTest->m_outputDir + <span class="stringliteral">"/links.html"</span> ); <a name="l00618"></a>00618 list.open( IO_WriteOnly|IO_Append ); <a name="l00619"></a>00619 <a class="codeRef" href="qstring.html">QString</a> link, cl; <a name="l00620"></a>00620 link = <a class="codeRef" href="qstring.html">QString</a>( <span class="stringliteral">"<hr>%1 failures. (%2 expected failures)"</span> ) <a name="l00621"></a>00621 .<a class="codeRef" href="qstring.html#arg">arg</a>(regressionTest->m_failures_work ) <a name="l00622"></a>00622 .arg( regressionTest->m_failures_fail ); <a name="l00623"></a>00623 <span class="keywordflow">if</span> (regressionTest->m_failures_new) <a name="l00624"></a>00624 link += <a class="codeRef" href="qstring.html">QString</a>(<span class="stringliteral">" <span style=\"color:red;font-weight:bold\">(%1 new failures since %2)</span>"</span>) <a name="l00625"></a>00625 .<a class="codeRef" href="qstring.html#arg">arg</a>(regressionTest->m_failures_new) <a name="l00626"></a>00626 .arg(regressionTest->m_failureComp->group()); <a name="l00627"></a>00627 <span class="keywordflow">if</span> (regressionTest->m_passes_new) <a name="l00628"></a>00628 link += <a class="codeRef" href="qstring.html">QString</a>(<span class="stringliteral">" <p style=\"color:green;font-weight:bold\">%1 new passes since %2</p>"</span>) <a name="l00629"></a>00629 .<a class="codeRef" href="qstring.html#arg">arg</a>(regressionTest->m_passes_new) <a name="l00630"></a>00630 .arg(regressionTest->m_failureComp->group()); <a name="l00631"></a>00631 list.writeBlock( link.<a class="codeRef" href="qstring.html#latin1">latin1</a>(), link.<a class="codeRef" href="qstring.html#length">length</a>() ); <a name="l00632"></a>00632 list.close(); <a name="l00633"></a>00633 } <a name="l00634"></a>00634 } <a name="l00635"></a>00635 <a name="l00636"></a>00636 <span class="comment">// Only return a 0 exit code if all tests were successful</span> <a name="l00637"></a>00637 <span class="keywordflow">if</span> (regressionTest->m_failures_work == 0 && regressionTest->m_errors == 0) <a name="l00638"></a>00638 rv = 0; <a name="l00639"></a>00639 <a name="l00640"></a>00640 <span class="comment">// cleanup</span> <a name="l00641"></a>00641 <span class="keyword">delete</span> regressionTest; <a name="l00642"></a>00642 <span class="keyword">delete</span> part; <a name="l00643"></a>00643 <span class="keyword">delete</span> toplevel; <a name="l00644"></a>00644 <span class="comment">// delete fac;</span> <a name="l00645"></a>00645 <a name="l00646"></a>00646 <span class="keywordflow">return</span> rv; <a name="l00647"></a>00647 } <a name="l00648"></a>00648 <a name="l00649"></a>00649 <span class="comment">// -------------------------------------------------------------------------</span> <a name="l00650"></a>00650 <a name="l00651"></a>00651 RegressionTest *RegressionTest::curr = 0; <a name="l00652"></a>00652 <a name="l00653"></a>00653 RegressionTest::RegressionTest(KateDocument *part, <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKConfig.html">KConfig</a> *baseConfig, <a name="l00654"></a>00654 <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &baseDir, <a name="l00655"></a>00655 <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &outputDir, <span class="keywordtype">bool</span> _genOutput) <a name="l00656"></a>00656 : <a class="codeRef" href="qobject.html">QObject</a>(part) <a name="l00657"></a>00657 { <a name="l00658"></a>00658 m_part = part; <a name="l00659"></a>00659 m_view = <span class="keyword">static_cast<</span>KateView *<span class="keyword">></span>(m_part->widget()); <a name="l00660"></a>00660 m_baseConfig = baseConfig; <a name="l00661"></a>00661 m_baseDir = baseDir; <a name="l00662"></a>00662 m_baseDir = m_baseDir.<a class="codeRef" href="qstring.html#replace">replace</a>( <span class="stringliteral">"//"</span>, <span class="stringliteral">"/"</span> ); <a name="l00663"></a>00663 <span class="keywordflow">if</span> ( m_baseDir.endsWith( <span class="stringliteral">"/"</span> ) ) <a name="l00664"></a>00664 m_baseDir = m_baseDir.left( m_baseDir.length() - 1 ); <a name="l00665"></a>00665 <span class="keywordflow">if</span> (outputDir.<a class="codeRef" href="qstring.html#isEmpty">isEmpty</a>()) <a name="l00666"></a>00666 m_outputDir = m_baseDir + <span class="stringliteral">"/output"</span>; <a name="l00667"></a>00667 <span class="keywordflow">else</span> <a name="l00668"></a>00668 m_outputDir = outputDir; <a name="l00669"></a>00669 createMissingDirs(m_outputDir + <span class="stringliteral">"/"</span>); <a name="l00670"></a>00670 m_keepOutput = <span class="keyword">false</span>; <a name="l00671"></a>00671 m_genOutput = _genOutput; <a name="l00672"></a>00672 m_failureComp = 0; <a name="l00673"></a>00673 m_failureSave = 0; <a name="l00674"></a>00674 m_showGui = <span class="keyword">false</span>; <a name="l00675"></a>00675 m_passes_work = m_passes_fail = m_passes_new = 0; <a name="l00676"></a>00676 m_failures_work = m_failures_fail = m_failures_new = 0; <a name="l00677"></a>00677 m_errors = 0; <a name="l00678"></a>00678 <a name="l00679"></a>00679 ::unlink( <a class="codeRef" href="qfile.html#encodeName">QFile::encodeName</a>( m_outputDir + <span class="stringliteral">"/links.html"</span> ) ); <a name="l00680"></a>00680 <a class="codeRef" href="qfile.html">QFile</a> f( m_outputDir + <span class="stringliteral">"/empty.html"</span> ); <a name="l00681"></a>00681 <a class="codeRef" href="qstring.html">QString</a> s; <a name="l00682"></a>00682 f.open( IO_WriteOnly | IO_Truncate ); <a name="l00683"></a>00683 s = <span class="stringliteral">"<html><body>Follow the white rabbit"</span>; <a name="l00684"></a>00684 f.writeBlock( s.<a class="codeRef" href="qstring.html#latin1">latin1</a>(), s.<a class="codeRef" href="qstring.html#length">length</a>() ); <a name="l00685"></a>00685 f.close(); <a name="l00686"></a>00686 f.setName( m_outputDir + <span class="stringliteral">"/index.html"</span> ); <a name="l00687"></a>00687 f.open( IO_WriteOnly | IO_Truncate ); <a name="l00688"></a>00688 s = <span class="stringliteral">"<html><frameset cols=150,*><frame src=links.html><frame name=content src=empty.html>"</span>; <a name="l00689"></a>00689 f.writeBlock( s.<a class="codeRef" href="qstring.html#latin1">latin1</a>(), s.<a class="codeRef" href="qstring.html#length">length</a>() ); <a name="l00690"></a>00690 f.close(); <a name="l00691"></a>00691 <a name="l00692"></a>00692 curr = <span class="keyword">this</span>; <a name="l00693"></a>00693 } <a name="l00694"></a>00694 <a name="l00695"></a>00695 <span class="preprocessor">#include <qobjectlist.h></span> <a name="l00696"></a>00696 <a name="l00697"></a>00697 <span class="keyword">static</span> <a class="codeRef" href="qstringlist.html">QStringList</a> readListFile( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &filename ) <a name="l00698"></a>00698 { <a name="l00699"></a>00699 <span class="comment">// Read ignore file for this directory</span> <a name="l00700"></a>00700 <a class="codeRef" href="qstring.html">QString</a> ignoreFilename = filename; <a name="l00701"></a>00701 <a class="codeRef" href="qfileinfo.html">QFileInfo</a> ignoreInfo(ignoreFilename); <a name="l00702"></a>00702 <a class="codeRef" href="qstringlist.html">QStringList</a> ignoreFiles; <a name="l00703"></a>00703 <span class="keywordflow">if</span> (ignoreInfo.exists()) { <a name="l00704"></a>00704 <a class="codeRef" href="qfile.html">QFile</a> ignoreFile(ignoreFilename); <a name="l00705"></a>00705 <span class="keywordflow">if</span> (!ignoreFile.open(IO_ReadOnly)) { <a name="l00706"></a>00706 fprintf(stderr,<span class="stringliteral">"Can't open %s\n"</span>,ignoreFilename.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l00707"></a>00707 exit(1); <a name="l00708"></a>00708 } <a name="l00709"></a>00709 <a class="codeRef" href="qtextstream.html">QTextStream</a> ignoreStream(&ignoreFile); <a name="l00710"></a>00710 <a class="codeRef" href="qstring.html">QString</a> line; <a name="l00711"></a>00711 <span class="keywordflow">while</span> (!(line = ignoreStream.readLine()).isNull()) <a name="l00712"></a>00712 ignoreFiles.append(line); <a name="l00713"></a>00713 ignoreFile.close(); <a name="l00714"></a>00714 } <a name="l00715"></a>00715 <span class="keywordflow">return</span> ignoreFiles; <a name="l00716"></a>00716 } <a name="l00717"></a>00717 <a name="l00718"></a>00718 RegressionTest::~RegressionTest() <a name="l00719"></a>00719 { <a name="l00720"></a>00720 <span class="comment">// Important! Delete comparison config *first* as saver config</span> <a name="l00721"></a>00721 <span class="comment">// might point to the same physical file.</span> <a name="l00722"></a>00722 <span class="keyword">delete</span> m_failureComp; <a name="l00723"></a>00723 <span class="keyword">delete</span> m_failureSave; <a name="l00724"></a>00724 } <a name="l00725"></a>00725 <a name="l00726"></a>00726 <span class="keywordtype">void</span> RegressionTest::setFailureSnapshotConfig(<a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKConfig.html">KConfig</a> *cfg, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &sname) <a name="l00727"></a>00727 { <a name="l00728"></a>00728 Q_ASSERT(cfg); <a name="l00729"></a>00729 m_failureComp = cfg; <a name="l00730"></a>00730 m_failureComp-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKConfigBase.html#a1754e470553c9f9ac2556a9d63ce61c9">setGroup</a>(sname); <a name="l00731"></a>00731 } <a name="l00732"></a>00732 <a name="l00733"></a>00733 <span class="keywordtype">void</span> RegressionTest::setFailureSnapshotSaver(<a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKConfig.html">KConfig</a> *cfg, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &sname) <a name="l00734"></a>00734 { <a name="l00735"></a>00735 Q_ASSERT(cfg); <a name="l00736"></a>00736 m_failureSave = cfg; <a name="l00737"></a>00737 m_failureSave-><a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKConfigBase.html#a1754e470553c9f9ac2556a9d63ce61c9">setGroup</a>(sname); <a name="l00738"></a>00738 } <a name="l00739"></a>00739 <a name="l00740"></a>00740 <a class="codeRef" href="qstringlist.html">QStringList</a> RegressionTest::concatListFiles(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &relPath, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &filename) <a name="l00741"></a>00741 { <a name="l00742"></a>00742 <a class="codeRef" href="qstringlist.html">QStringList</a> cmds; <a name="l00743"></a>00743 <span class="keywordtype">int</span> pos = relPath.<a class="codeRef" href="qstring.html#findRev">findRev</a>(<span class="charliteral">'/'</span>); <a name="l00744"></a>00744 <span class="keywordflow">if</span> (pos >= 0) <a name="l00745"></a>00745 cmds += concatListFiles(relPath.<a class="codeRef" href="qstring.html#left">left</a>(pos), filename); <a name="l00746"></a>00746 cmds += readListFile(m_baseDir + <span class="stringliteral">"/tests/"</span> + relPath + <span class="stringliteral">"/"</span> + filename); <a name="l00747"></a>00747 <span class="keywordflow">return</span> cmds; <a name="l00748"></a>00748 } <a name="l00749"></a>00749 <a name="l00750"></a>00750 <span class="keywordtype">bool</span> RegressionTest::runTests(<a class="codeRef" href="qstring.html">QString</a> relPath, <span class="keywordtype">bool</span> mustExist, <span class="keywordtype">int</span> known_failure) <a name="l00751"></a>00751 { <a name="l00752"></a>00752 m_currentOutput = QString::null; <a name="l00753"></a>00753 <a name="l00754"></a>00754 <span class="keywordflow">if</span> (!<a class="codeRef" href="qfile.html">QFile</a>(m_baseDir + <span class="stringliteral">"/tests/"</span>+relPath).exists()) { <a name="l00755"></a>00755 fprintf(stderr,<span class="stringliteral">"%s: No such file or directory\n"</span>,relPath.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l00756"></a>00756 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00757"></a>00757 } <a name="l00758"></a>00758 <a name="l00759"></a>00759 <a class="codeRef" href="qstring.html">QString</a> fullPath = m_baseDir + <span class="stringliteral">"/tests/"</span>+relPath; <a name="l00760"></a>00760 <a class="codeRef" href="qfileinfo.html">QFileInfo</a> info(fullPath); <a name="l00761"></a>00761 <a name="l00762"></a>00762 <span class="keywordflow">if</span> (!info.exists() && mustExist) { <a name="l00763"></a>00763 fprintf(stderr,<span class="stringliteral">"%s: No such file or directory\n"</span>,relPath.latin1()); <a name="l00764"></a>00764 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00765"></a>00765 } <a name="l00766"></a>00766 <a name="l00767"></a>00767 <span class="keywordflow">if</span> (!info.isReadable() && mustExist) { <a name="l00768"></a>00768 fprintf(stderr,<span class="stringliteral">"%s: Access denied\n"</span>,relPath.latin1()); <a name="l00769"></a>00769 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00770"></a>00770 } <a name="l00771"></a>00771 <a name="l00772"></a>00772 <span class="keywordflow">if</span> (info.isDir()) { <a name="l00773"></a>00773 <a class="codeRef" href="qstringlist.html">QStringList</a> ignoreFiles = readListFile( m_baseDir + <span class="stringliteral">"/tests/"</span>+relPath+<span class="stringliteral">"/ignore"</span> ); <a name="l00774"></a>00774 <a class="codeRef" href="qstringlist.html">QStringList</a> failureFiles = readListFile( m_baseDir + <span class="stringliteral">"/tests/"</span>+relPath+<span class="stringliteral">"/KNOWN_FAILURES"</span> ); <a name="l00775"></a>00775 <a name="l00776"></a>00776 <span class="comment">// Run each test in this directory, recusively</span> <a name="l00777"></a>00777 <a class="codeRef" href="qdir.html">QDir</a> sourceDir(m_baseDir + <span class="stringliteral">"/tests/"</span>+relPath); <a name="l00778"></a>00778 <span class="keywordflow">for</span> (uint fileno = 0; fileno < sourceDir.count(); fileno++) { <a name="l00779"></a>00779 <a class="codeRef" href="qstring.html">QString</a> filename = sourceDir[fileno]; <a name="l00780"></a>00780 <a class="codeRef" href="qstring.html">QString</a> relFilename = relPath.<a class="codeRef" href="qstring.html#isEmpty">isEmpty</a>() ? filename : relPath+<span class="stringliteral">"/"</span>+filename; <a name="l00781"></a>00781 <a name="l00782"></a>00782 <span class="keywordflow">if</span> (filename.startsWith(<span class="stringliteral">"."</span>) || ignoreFiles.contains(filename) ) <a name="l00783"></a>00783 <span class="keywordflow">continue</span>; <a name="l00784"></a>00784 <span class="keywordtype">int</span> failure_type = NoFailure; <a name="l00785"></a>00785 <span class="keywordflow">if</span> ( failureFiles.contains( filename ) ) <a name="l00786"></a>00786 failure_type |= AllFailure; <a name="l00787"></a>00787 <span class="keywordflow">if</span> ( failureFiles.contains ( filename + <span class="stringliteral">"-result"</span> ) ) <a name="l00788"></a>00788 failure_type |= ResultFailure; <a name="l00789"></a>00789 runTests(relFilename, <span class="keyword">false</span>, failure_type); <a name="l00790"></a>00790 } <a name="l00791"></a>00791 } <a name="l00792"></a>00792 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (info.isFile()) { <a name="l00793"></a>00793 <a name="l00794"></a>00794 <a class="codeRef" href="qstring.html">QString</a> relativeDir = <a class="codeRef" href="qfileinfo.html">QFileInfo</a>(relPath).<a class="codeRef" href="qfileinfo.html#dirPath">dirPath</a>(); <a name="l00795"></a>00795 <a class="codeRef" href="qstring.html">QString</a> filename = info.fileName(); <a name="l00796"></a>00796 m_currentBase = m_baseDir + <span class="stringliteral">"/tests/"</span>+relativeDir; <a name="l00797"></a>00797 m_currentCategory = relativeDir; <a name="l00798"></a>00798 m_currentTest = filename; <a name="l00799"></a>00799 m_known_failures = known_failure; <a name="l00800"></a>00800 m_outputCustomised = <span class="keyword">false</span>; <a name="l00801"></a>00801 <span class="comment">// gather commands</span> <a name="l00802"></a>00802 <span class="comment">// directory-specific commands</span> <a name="l00803"></a>00803 <a class="codeRef" href="qstringlist.html">QStringList</a> commands = concatListFiles(relPath, <span class="stringliteral">".kateconfig-commands"</span>); <a name="l00804"></a>00804 <span class="comment">// testcase-specific commands</span> <a name="l00805"></a>00805 commands += readListFile(m_currentBase + <span class="stringliteral">"/"</span> + filename + <span class="stringliteral">"-commands"</span>); <a name="l00806"></a>00806 <a name="l00807"></a>00807 rereadConfig(); <span class="comment">// reset options to default</span> <a name="l00808"></a>00808 <span class="keywordflow">if</span> ( filename.<a class="codeRef" href="qstring.html#endsWith">endsWith</a>(<span class="stringliteral">".txt"</span>) ) { <a name="l00809"></a>00809 <span class="preprocessor">#if 0</span> <a name="l00810"></a>00810 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( relPath.startsWith( <span class="stringliteral">"domts/"</span> ) && !m_runJS ) <a name="l00811"></a>00811 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00812"></a>00812 <span class="keywordflow">if</span> ( relPath.startsWith( <span class="stringliteral">"ecma/"</span> ) && !m_runJS ) <a name="l00813"></a>00813 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00814"></a>00814 <span class="preprocessor">#endif</span> <a name="l00815"></a>00815 <span class="preprocessor"></span><span class="comment">// if ( m_runHTML )</span> <a name="l00816"></a>00816 testStaticFile(relPath, commands); <a name="l00817"></a>00817 } <a name="l00818"></a>00818 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mustExist) { <a name="l00819"></a>00819 fprintf(stderr,<span class="stringliteral">"%s: Not a valid test file (must be .txt)\n"</span>,relPath.latin1()); <a name="l00820"></a>00820 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00821"></a>00821 } <a name="l00822"></a>00822 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mustExist) { <a name="l00823"></a>00823 fprintf(stderr,<span class="stringliteral">"%s: Not a regular file\n"</span>,relPath.latin1()); <a name="l00824"></a>00824 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00825"></a>00825 } <a name="l00826"></a>00826 <a name="l00827"></a>00827 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00828"></a>00828 } <a name="l00829"></a>00829 <a name="l00830"></a>00830 <span class="keywordtype">void</span> RegressionTest::createLink( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a>& test, <span class="keywordtype">int</span> failures ) <a name="l00831"></a>00831 { <a name="l00832"></a>00832 createMissingDirs( m_outputDir + <span class="stringliteral">"/"</span> + test + <span class="stringliteral">"-compare.html"</span> ); <a name="l00833"></a>00833 <a name="l00834"></a>00834 <a class="codeRef" href="qfile.html">QFile</a> list( m_outputDir + <span class="stringliteral">"/links.html"</span> ); <a name="l00835"></a>00835 list.open( IO_WriteOnly|IO_Append ); <a name="l00836"></a>00836 <a class="codeRef" href="qstring.html">QString</a> link; <a name="l00837"></a>00837 link = <a class="codeRef" href="qstring.html">QString</a>( <span class="stringliteral">"<a href=\"%1\" target=\"content\" title=\"%2\">"</span> ) <a name="l00838"></a>00838 .<a class="codeRef" href="qstring.html#arg">arg</a>( test + <span class="stringliteral">"-compare.html"</span> ) <a name="l00839"></a>00839 .arg( test ); <a name="l00840"></a>00840 link += m_currentTest; <a name="l00841"></a>00841 link += <span class="stringliteral">"</a> "</span>; <a name="l00842"></a>00842 <span class="keywordflow">if</span> (failures & NewFailure) <a name="l00843"></a>00843 link += <span class="stringliteral">"<span style=\"font-weight:bold;color:red\">"</span>; <a name="l00844"></a>00844 link += <span class="stringliteral">"["</span>; <a name="l00845"></a>00845 <span class="keywordflow">if</span> ( failures & ResultFailure ) <a name="l00846"></a>00846 link += <span class="stringliteral">"R"</span>; <a name="l00847"></a>00847 link += <span class="stringliteral">"]"</span>; <a name="l00848"></a>00848 <span class="keywordflow">if</span> (failures & NewFailure) <a name="l00849"></a>00849 link += <span class="stringliteral">"</span>"</span>; <a name="l00850"></a>00850 link += <span class="stringliteral">"<br>\n"</span>; <a name="l00851"></a>00851 list.writeBlock( link.<a class="codeRef" href="qstring.html#latin1">latin1</a>(), link.<a class="codeRef" href="qstring.html#length">length</a>() ); <a name="l00852"></a>00852 list.close(); <a name="l00853"></a>00853 } <a name="l00854"></a>00854 <a name="l00861"></a>00861 <span class="keyword">static</span> <a class="codeRef" href="qstring.html">QString</a> makeRelativePath(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &base, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &path) <a name="l00862"></a>00862 { <a name="l00863"></a>00863 <a class="codeRef" href="qstring.html">QString</a> absBase = <a class="codeRef" href="qfileinfo.html">QFileInfo</a>(base).<a class="codeRef" href="qfileinfo.html#absFilePath">absFilePath</a>(); <a name="l00864"></a>00864 <a class="codeRef" href="qstring.html">QString</a> absPath = <a class="codeRef" href="qfileinfo.html">QFileInfo</a>(path).<a class="codeRef" href="qfileinfo.html#absFilePath">absFilePath</a>(); <a name="l00865"></a>00865 <span class="comment">// kdDebug() << "absPath: \"" << absPath << "\"" << endl;</span> <a name="l00866"></a>00866 <span class="comment">// kdDebug() << "absBase: \"" << absBase << "\"" << endl;</span> <a name="l00867"></a>00867 <a name="l00868"></a>00868 <span class="comment">// walk up to common ancestor directory</span> <a name="l00869"></a>00869 <span class="keywordtype">int</span> pos = 0; <a name="l00870"></a>00870 <span class="keywordflow">do</span> { <a name="l00871"></a>00871 pos++; <a name="l00872"></a>00872 <span class="keywordtype">int</span> newpos = absBase.<a class="codeRef" href="qstring.html#find">find</a>(<span class="charliteral">'/'</span>, pos); <a name="l00873"></a>00873 <span class="keywordflow">if</span> (newpos == -1) newpos = absBase.<a class="codeRef" href="qstring.html#length">length</a>(); <a name="l00874"></a>00874 <a class="codeRef" href="qconststring.html">QConstString</a> cmpPathComp(absPath.<a class="codeRef" href="qstring.html#unicode">unicode</a>() + pos, newpos - pos); <a name="l00875"></a>00875 <a class="codeRef" href="qconststring.html">QConstString</a> cmpBaseComp(absBase.<a class="codeRef" href="qstring.html#unicode">unicode</a>() + pos, newpos - pos); <a name="l00876"></a>00876 <span class="comment">// kdDebug() << "cmpPathComp: \"" << cmpPathComp.string() << "\"" << endl;</span> <a name="l00877"></a>00877 <span class="comment">// kdDebug() << "cmpBaseComp: \"" << cmpBaseComp.string() << "\"" << endl;</span> <a name="l00878"></a>00878 <span class="comment">// kdDebug() << "pos: " << pos << " newpos: " << newpos << endl;</span> <a name="l00879"></a>00879 <span class="keywordflow">if</span> (cmpPathComp.string() != cmpBaseComp.string()) { pos--; <span class="keywordflow">break</span>; } <a name="l00880"></a>00880 pos = newpos; <a name="l00881"></a>00881 } <span class="keywordflow">while</span> (pos < (<span class="keywordtype">int</span>)absBase.<a class="codeRef" href="qstring.html#length">length</a>() && pos < (int)absPath.<a class="codeRef" href="qstring.html#length">length</a>()); <a name="l00882"></a>00882 <span class="keywordtype">int</span> basepos = pos < (int)absBase.<a class="codeRef" href="qstring.html#length">length</a>() ? pos + 1 : pos; <a name="l00883"></a>00883 <span class="keywordtype">int</span> pathpos = pos < (int)absPath.<a class="codeRef" href="qstring.html#length">length</a>() ? pos + 1 : pos; <a name="l00884"></a>00884 <a name="l00885"></a>00885 <span class="comment">// kdDebug() << "basepos " << basepos << " pathpos " << pathpos << endl;</span> <a name="l00886"></a>00886 <a name="l00887"></a>00887 <a class="codeRef" href="qstring.html">QString</a> rel; <a name="l00888"></a>00888 { <a name="l00889"></a>00889 <a class="codeRef" href="qconststring.html">QConstString</a> relBase(absBase.<a class="codeRef" href="qstring.html#unicode">unicode</a>() + basepos, absBase.<a class="codeRef" href="qstring.html#length">length</a>() - basepos); <a name="l00890"></a>00890 <a class="codeRef" href="qconststring.html">QConstString</a> relPath(absPath.<a class="codeRef" href="qstring.html#unicode">unicode</a>() + pathpos, absPath.<a class="codeRef" href="qstring.html#length">length</a>() - pathpos); <a name="l00891"></a>00891 <span class="comment">// generate as many .. as there are path elements in relBase</span> <a name="l00892"></a>00892 <span class="keywordflow">if</span> (relBase.string().length() > 0) { <a name="l00893"></a>00893 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = relBase.string().contains(<span class="charliteral">'/'</span>); i > 0; --i) <a name="l00894"></a>00894 rel += <span class="stringliteral">"../"</span>; <a name="l00895"></a>00895 rel += <span class="stringliteral">".."</span>; <a name="l00896"></a>00896 <span class="keywordflow">if</span> (relPath.string().length() > 0) rel += <span class="stringliteral">"/"</span>; <a name="l00897"></a>00897 } <a name="l00898"></a>00898 rel += relPath.string(); <a name="l00899"></a>00899 } <a name="l00900"></a>00900 <span class="keywordflow">return</span> rel; <a name="l00901"></a>00901 } <a name="l00902"></a>00902 <a name="l00904"></a>00904 <span class="keyword">static</span> <span class="keywordtype">void</span> pause(<span class="keywordtype">int</span> msec) <a name="l00905"></a>00905 { <a name="l00906"></a>00906 <a class="codeRef" href="qtime.html">QTime</a> t; <a name="l00907"></a>00907 t.<a class="codeRef" href="qtime.html#start">start</a>(); <a name="l00908"></a>00908 <span class="keywordflow">do</span> { <a name="l00909"></a>00909 kapp->processEvents(); <a name="l00910"></a>00910 } <span class="keywordflow">while</span> (t.<a class="codeRef" href="qtime.html#elapsed">elapsed</a>() < msec); <a name="l00911"></a>00911 } <a name="l00912"></a>00912 <a name="l00913"></a>00913 <span class="keywordtype">void</span> RegressionTest::doFailureReport( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a>& test, <span class="keywordtype">int</span> failures ) <a name="l00914"></a>00914 { <a name="l00915"></a>00915 <span class="keywordflow">if</span> ( failures == NoFailure ) { <a name="l00916"></a>00916 ::unlink( <a class="codeRef" href="qfile.html#encodeName">QFile::encodeName</a>( m_outputDir + <span class="stringliteral">"/"</span> + test + <span class="stringliteral">"-compare.html"</span> ) ); <a name="l00917"></a>00917 <span class="keywordflow">return</span>; <a name="l00918"></a>00918 } <a name="l00919"></a>00919 <a name="l00920"></a>00920 createLink( test, failures ); <a name="l00921"></a>00921 <a name="l00922"></a>00922 <a class="codeRef" href="qfile.html">QFile</a> compare( m_outputDir + <span class="stringliteral">"/"</span> + test + <span class="stringliteral">"-compare.html"</span> ); <a name="l00923"></a>00923 <a name="l00924"></a>00924 <a class="codeRef" href="qstring.html">QString</a> testFile = <a class="codeRef" href="qfileinfo.html">QFileInfo</a>(test).<a class="codeRef" href="qfileinfo.html#fileName">fileName</a>(); <a name="l00925"></a>00925 <a name="l00926"></a>00926 <a class="codeRef" href="qstring.html">QString</a> renderDiff; <a name="l00927"></a>00927 <a class="codeRef" href="qstring.html">QString</a> domDiff; <a name="l00928"></a>00928 <a name="l00929"></a>00929 <a class="codeRef" href="qstring.html">QString</a> relOutputDir = makeRelativePath(m_baseDir, m_outputDir); <a name="l00930"></a>00930 <a name="l00931"></a>00931 <span class="comment">// are blocking reads possible with KProcess?</span> <a name="l00932"></a>00932 <span class="keywordtype">char</span> pwd[PATH_MAX]; <a name="l00933"></a>00933 (void) getcwd( pwd, PATH_MAX ); <a name="l00934"></a>00934 chdir( <a class="codeRef" href="qfile.html#encodeName">QFile::encodeName</a>( m_baseDir ) ); <a name="l00935"></a>00935 <a name="l00936"></a>00936 <span class="keywordflow">if</span> ( failures & ResultFailure ) { <a name="l00937"></a>00937 domDiff += <span class="stringliteral">"<pre>"</span>; <a name="l00938"></a>00938 FILE *pipe = popen( <a class="codeRef" href="qstring.html#fromLatin1">QString::fromLatin1</a>( <span class="stringliteral">"diff -u baseline/%1-result %3/%2-result"</span> ) <a name="l00939"></a>00939 .arg ( test, test, relOutputDir ).latin1(), <span class="stringliteral">"r"</span> ); <a name="l00940"></a>00940 <a class="codeRef" href="qtextistream.html">QTextIStream</a> *is = <span class="keyword">new</span> <a class="codeRef" href="qtextistream.html">QTextIStream</a>( pipe ); <a name="l00941"></a>00941 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> line = 0; line < 100 && !is->eof(); ++line ) { <a name="l00942"></a>00942 <a class="codeRef" href="qstring.html">QString</a> line = is->readLine(); <a name="l00943"></a>00943 line = line.<a class="codeRef" href="qstring.html#replace">replace</a>( <span class="charliteral">'<'</span>, <span class="stringliteral">"&lt;"</span> ); <a name="l00944"></a>00944 line = line.<a class="codeRef" href="qstring.html#replace">replace</a>( <span class="charliteral">'>'</span>, <span class="stringliteral">"&gt;"</span> ); <a name="l00945"></a>00945 domDiff += line + <span class="stringliteral">"\n"</span>; <a name="l00946"></a>00946 } <a name="l00947"></a>00947 <span class="keyword">delete</span> is; <a name="l00948"></a>00948 pclose( pipe ); <a name="l00949"></a>00949 domDiff += <span class="stringliteral">"</pre>"</span>; <a name="l00950"></a>00950 } <a name="l00951"></a>00951 <a name="l00952"></a>00952 chdir( pwd ); <a name="l00953"></a>00953 <a name="l00954"></a>00954 <span class="comment">// create a relative path so that it works via web as well. ugly</span> <a name="l00955"></a>00955 <a class="codeRef" href="qstring.html">QString</a> relpath = makeRelativePath(m_outputDir + <span class="stringliteral">"/"</span> <a name="l00956"></a>00956 + <a class="codeRef" href="qfileinfo.html">QFileInfo</a>(test).dirPath(), m_baseDir); <a name="l00957"></a>00957 <a name="l00958"></a>00958 compare.open( IO_WriteOnly|IO_Truncate ); <a name="l00959"></a>00959 <a class="codeRef" href="qstring.html">QString</a> cl; <a name="l00960"></a>00960 cl = <a class="codeRef" href="qstring.html">QString</a>( <span class="stringliteral">"<html><head><title>%1</title>"</span> ).<a class="codeRef" href="qstring.html#arg">arg</a>( test ); <a name="l00961"></a>00961 cl += <a class="codeRef" href="qstring.html">QString</a>( <span class="stringliteral">"<script>\n"</span> <a name="l00962"></a>00962 <span class="stringliteral">"var pics = new Array();\n"</span> <a name="l00963"></a>00963 <span class="stringliteral">"pics[0]=new Image();\n"</span> <a name="l00964"></a>00964 <span class="stringliteral">"pics[0].src = '%1';\n"</span> <a name="l00965"></a>00965 <span class="stringliteral">"pics[1]=new Image();\n"</span> <a name="l00966"></a>00966 <span class="stringliteral">"pics[1].src = '%2';\n"</span> <a name="l00967"></a>00967 <span class="stringliteral">"var doflicker = 1;\n"</span> <a name="l00968"></a>00968 <span class="stringliteral">"var t = 1;\n"</span> <a name="l00969"></a>00969 <span class="stringliteral">"var lastb=0;\n"</span> ) <a name="l00970"></a>00970 .<a class="codeRef" href="qstring.html#arg">arg</a>( relpath+<span class="stringliteral">"/baseline/"</span>+test+<span class="stringliteral">"-dump.png"</span> ) <a name="l00971"></a>00971 .arg( testFile+<span class="stringliteral">"-dump.png"</span> ); <a name="l00972"></a>00972 cl += <a class="codeRef" href="qstring.html">QString</a>( <span class="stringliteral">"function toggleVisible(visible) {\n"</span> <a name="l00973"></a>00973 <span class="stringliteral">" document.getElementById('render').style.visibility= visible == 'render' ? 'visible' : 'hidden';\n"</span> <a name="l00974"></a>00974 <span class="stringliteral">" document.getElementById('image').style.visibility= visible == 'image' ? 'visible' : 'hidden';\n"</span> <a name="l00975"></a>00975 <span class="stringliteral">" document.getElementById('dom').style.visibility= visible == 'dom' ? 'visible' : 'hidden';\n"</span> <a name="l00976"></a>00976 <span class="stringliteral">"}\n"</span> <a name="l00977"></a>00977 <span class="stringliteral">"function show() { document.getElementById('image').src = pics[t].src; "</span> <a name="l00978"></a>00978 <span class="stringliteral">"document.getElementById('image').style.borderColor = t && !doflicker ? 'red' : 'gray';\n"</span> <a name="l00979"></a>00979 <span class="stringliteral">"toggleVisible('image');\n"</span> <a name="l00980"></a>00980 <span class="stringliteral">"}"</span> ); <a name="l00981"></a>00981 cl += <a class="codeRef" href="qstring.html">QString</a> ( <span class="stringliteral">"function runSlideShow(){\n"</span> <a name="l00982"></a>00982 <span class="stringliteral">" document.getElementById('image').src = pics[t].src;\n"</span> <a name="l00983"></a>00983 <span class="stringliteral">" if (doflicker)\n"</span> <a name="l00984"></a>00984 <span class="stringliteral">" t = 1 - t;\n"</span> <a name="l00985"></a>00985 <span class="stringliteral">" setTimeout('runSlideShow()', 200);\n"</span> <a name="l00986"></a>00986 <span class="stringliteral">"}\n"</span> <a name="l00987"></a>00987 <span class="stringliteral">"function m(b) { if (b == lastb) return; document.getElementById('b'+b).className='buttondown';\n"</span> <a name="l00988"></a>00988 <span class="stringliteral">" var e = document.getElementById('b'+lastb);\n"</span> <a name="l00989"></a>00989 <span class="stringliteral">" if(e) e.className='button';\n"</span> <a name="l00990"></a>00990 <span class="stringliteral">" lastb = b;\n"</span> <a name="l00991"></a>00991 <span class="stringliteral">"}\n"</span> <a name="l00992"></a>00992 <span class="stringliteral">"function showRender() { doflicker=0;toggleVisible('render')\n"</span> <a name="l00993"></a>00993 <span class="stringliteral">"}\n"</span> <a name="l00994"></a>00994 <span class="stringliteral">"function showDom() { doflicker=0;toggleVisible('dom')\n"</span> <a name="l00995"></a>00995 <span class="stringliteral">"}\n"</span> <a name="l00996"></a>00996 <span class="stringliteral">"</script>\n"</span>); <a name="l00997"></a>00997 <a name="l00998"></a>00998 cl += <a class="codeRef" href="qstring.html">QString</a> (<span class="stringliteral">"<style>\n"</span> <a name="l00999"></a>00999 <span class="stringliteral">".buttondown { cursor: pointer; padding: 0px 20px; color: white; background-color: blue; border: inset blue 2px;}\n"</span> <a name="l01000"></a>01000 <span class="stringliteral">".button { cursor: pointer; padding: 0px 20px; color: black; background-color: white; border: outset blue 2px;}\n"</span> <a name="l01001"></a>01001 <span class="stringliteral">".diff { position: absolute; left: 10px; top: 100px; visibility: hidden; border: 1px black solid; background-color: white; color: black; /* width: 800; height: 600; overflow: scroll; */ }\n"</span> <a name="l01002"></a>01002 <span class="stringliteral">"</style>\n"</span> ); <a name="l01003"></a>01003 <a name="l01004"></a>01004 cl += <a class="codeRef" href="qstring.html">QString</a>( <span class="stringliteral">"<body onload=\"m(5); toggleVisible('dom');\""</span> ); <a name="l01005"></a>01005 cl += <a class="codeRef" href="qstring.html">QString</a>(<span class="stringliteral">" text=black bgcolor=gray>\n<h1>%3</h1>\n"</span> ).<a class="codeRef" href="qstring.html#arg">arg</a>( test ); <a name="l01006"></a>01006 <span class="keywordflow">if</span> ( renderDiff.<a class="codeRef" href="qstring.html#length">length</a>() ) <a name="l01007"></a>01007 cl += <span class="stringliteral">"<span id='b4' class='button' onclick='showRender();m(4)'>R-DIFF</span>&nbsp;\n"</span>; <a name="l01008"></a>01008 <span class="keywordflow">if</span> ( domDiff.<a class="codeRef" href="qstring.html#length">length</a>() ) <a name="l01009"></a>01009 cl += <span class="stringliteral">"<span id='b5' class='button' onclick='showDom();m(5);'>D-DIFF</span>&nbsp;\n"</span>; <a name="l01010"></a>01010 <span class="comment">// The test file always exists - except for checkOutput called from *.js files</span> <a name="l01011"></a>01011 <span class="keywordflow">if</span> ( <a class="codeRef" href="qfile.html#exists-2">QFile::exists</a>( m_baseDir + <span class="stringliteral">"/tests/"</span>+ test ) ) <a name="l01012"></a>01012 cl += <a class="codeRef" href="qstring.html">QString</a>( <span class="stringliteral">"<a class=button href=\"%1\">HTML</a>&nbsp;"</span> ) <a name="l01013"></a>01013 .<a class="codeRef" href="qstring.html#arg">arg</a>( relpath+<span class="stringliteral">"/tests/"</span>+test ); <a name="l01014"></a>01014 <a name="l01015"></a>01015 cl += <a class="codeRef" href="qstring.html">QString</a>( <span class="stringliteral">"<hr>"</span> <a name="l01016"></a>01016 <span class="stringliteral">"<img style='border: solid 5px gray' src=\"%1\" id='image'>"</span> ) <a name="l01017"></a>01017 .<a class="codeRef" href="qstring.html#arg">arg</a>( relpath+<span class="stringliteral">"/baseline/"</span>+test+<span class="stringliteral">"-dump.png"</span> ); <a name="l01018"></a>01018 <a name="l01019"></a>01019 cl += <span class="stringliteral">"<div id='render' class='diff'>"</span> + renderDiff + <span class="stringliteral">"</div>"</span>; <a name="l01020"></a>01020 cl += <span class="stringliteral">"<div id='dom' class='diff'>"</span> + domDiff + <span class="stringliteral">"</div>"</span>; <a name="l01021"></a>01021 <a name="l01022"></a>01022 cl += <span class="stringliteral">"</body></html>"</span>; <a name="l01023"></a>01023 compare.writeBlock( cl.<a class="codeRef" href="qstring.html#latin1">latin1</a>(), cl.<a class="codeRef" href="qstring.html#length">length</a>() ); <a name="l01024"></a>01024 compare.close(); <a name="l01025"></a>01025 } <a name="l01026"></a>01026 <a name="l01027"></a>01027 <span class="keywordtype">void</span> RegressionTest::testStaticFile(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> & filename, <span class="keyword">const</span> <a class="codeRef" href="qstringlist.html">QStringList</a> &commands) <a name="l01028"></a>01028 { <a name="l01029"></a>01029 qApp->mainWidget()->resize( 800, 600); <span class="comment">// restore size</span> <a name="l01030"></a>01030 <a name="l01031"></a>01031 <span class="comment">// Set arguments</span> <a name="l01032"></a>01032 <a class="codeRef" doxygen="kparts.tag:../../kparts/html/" href="../../kparts/html/structKParts_1_1URLArgs.html">KParts::URLArgs</a> args; <a name="l01033"></a>01033 <span class="keywordflow">if</span> (filename.<a class="codeRef" href="qstring.html#endsWith">endsWith</a>(<span class="stringliteral">".txt"</span>)) args.<a class="codeRef" doxygen="kparts.tag:../../kparts/html/" href="../../kparts/html/structKParts_1_1URLArgs.html#a5fc23c30f547e5a7a1a35e0d9b17e17b">serviceType</a> = <span class="stringliteral">"text/plain"</span>; <a name="l01034"></a>01034 m_part->browserExtension()->setURLArgs(args); <a name="l01035"></a>01035 <span class="comment">// load page</span> <a name="l01036"></a>01036 <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKURL.html">KURL</a> url; <a name="l01037"></a>01037 url.<a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKURL.html#a8992baac621d32c2aed7c97a26362b8d">setProtocol</a>(<span class="stringliteral">"file"</span>); <a name="l01038"></a>01038 url.<a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKURL.html#a6c0a0828b4b9f1126b13380076e2b2f3">setPath</a>(<a class="codeRef" href="qfileinfo.html">QFileInfo</a>(m_baseDir + <span class="stringliteral">"/tests/"</span>+filename).absFilePath()); <a name="l01039"></a>01039 m_part->openURL(url); <a name="l01040"></a>01040 <a name="l01041"></a>01041 <span class="comment">// inject commands</span> <a name="l01042"></a>01042 <span class="keywordflow">for</span> (QStringList::ConstIterator cit = commands.begin(); cit != commands.end(); ++cit) { <a name="l01043"></a>01043 <a class="codeRef" href="qstring.html">QString</a> str = (*cit).<a class="codeRef" href="qstring.html#stripWhiteSpace">stripWhiteSpace</a>(); <a name="l01044"></a>01044 <span class="keywordflow">if</span> (str.<a class="codeRef" href="qstring.html#isEmpty">isEmpty</a>() || str.<a class="codeRef" href="qstring.html#startsWith">startsWith</a>(<span class="stringliteral">"#"</span>)) <span class="keywordflow">continue</span>; <a name="l01045"></a>01045 <a class="code" href="classKate_1_1Command.html" title="Kate Commands.">Kate::Command</a> *cmd = KateCmd::self()->queryCommand(str); <a name="l01046"></a>01046 <span class="keywordflow">if</span> (cmd) { <a name="l01047"></a>01047 <a class="codeRef" href="qstring.html">QString</a> msg; <a name="l01048"></a>01048 <span class="keywordflow">if</span> (!cmd-><a class="code" href="classKate_1_1Command.html#a13a4d74abc9ac01c641cb82ca835b522" title="Execute this command for the given view and cmd string, return a bool about success, msg for status.">exec</a>(m_view, str, msg)) <a name="l01049"></a>01049 fprintf(stderr, <span class="stringliteral">"ERROR executing command '%s': %s\n"</span>, str.<a class="codeRef" href="qstring.html#latin1">latin1</a>(), msg.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l01050"></a>01050 } <a name="l01051"></a>01051 } <a name="l01052"></a>01052 <a name="l01053"></a>01053 pause(200); <a name="l01054"></a>01054 <a name="l01055"></a>01055 Q_ASSERT(m_part->config()->configFlags() & KateDocumentConfig::cfDoxygenAutoTyping); <a name="l01056"></a>01056 <a name="l01057"></a>01057 <span class="keywordtype">bool</span> script_error = <span class="keyword">false</span>; <a name="l01058"></a>01058 { <a name="l01059"></a>01059 <span class="comment">// Execute script</span> <a name="l01060"></a>01060 TestJScriptEnv jsenv(m_part); <a name="l01061"></a>01061 jsenv.output()->setChangedFlag(&m_outputCustomised); <a name="l01062"></a>01062 jsenv.output()->setOutputString(&m_outputString); <a name="l01063"></a>01063 script_error = evalJS(jsenv.interpreter(), m_baseDir + <span class="stringliteral">"/tests/"</span>+<a class="codeRef" href="qfileinfo.html">QFileInfo</a>(filename).<a class="codeRef" href="qfileinfo.html#dirPath">dirPath</a>()+<span class="stringliteral">"/.kateconfig-script"</span>, <span class="keyword">true</span>) <a name="l01064"></a>01064 && evalJS(jsenv.interpreter(), m_baseDir + <span class="stringliteral">"/tests/"</span>+filename+<span class="stringliteral">"-script"</span>); <a name="l01065"></a>01065 } <a name="l01066"></a>01066 <a name="l01067"></a>01067 <span class="keywordtype">int</span> back_known_failures = m_known_failures; <a name="l01068"></a>01068 <a name="l01069"></a>01069 <span class="keywordflow">if</span> (!script_error) <span class="keywordflow">goto</span> bail_out; <a name="l01070"></a>01070 <a name="l01071"></a>01071 <span class="keywordflow">if</span> (m_showGui) kapp->processEvents(); <a name="l01072"></a>01072 <a name="l01073"></a>01073 <span class="keywordflow">if</span> ( m_genOutput ) { <a name="l01074"></a>01074 reportResult(checkOutput(filename+<span class="stringliteral">"-result"</span>), <span class="stringliteral">"result"</span>); <a name="l01075"></a>01075 } <span class="keywordflow">else</span> { <a name="l01076"></a>01076 <span class="keywordtype">int</span> failures = NoFailure; <a name="l01077"></a>01077 <a name="l01078"></a>01078 <span class="comment">// compare with output file</span> <a name="l01079"></a>01079 <span class="keywordflow">if</span> ( m_known_failures & ResultFailure) <a name="l01080"></a>01080 m_known_failures = AllFailure; <a name="l01081"></a>01081 <span class="keywordtype">bool</span> newfail; <a name="l01082"></a>01082 <span class="keywordflow">if</span> ( !reportResult( checkOutput(filename+<span class="stringliteral">"-result"</span>), <span class="stringliteral">"result"</span>, &newfail ) ) <a name="l01083"></a>01083 failures |= ResultFailure; <a name="l01084"></a>01084 <span class="keywordflow">if</span> (newfail) <a name="l01085"></a>01085 failures |= NewFailure; <a name="l01086"></a>01086 <a name="l01087"></a>01087 doFailureReport(filename, failures ); <a name="l01088"></a>01088 } <a name="l01089"></a>01089 <a name="l01090"></a>01090 bail_out: <a name="l01091"></a>01091 m_known_failures = back_known_failures; <a name="l01092"></a>01092 m_part->setModified(<span class="keyword">false</span>); <a name="l01093"></a>01093 m_part->closeURL(); <a name="l01094"></a>01094 } <a name="l01095"></a>01095 <a name="l01096"></a>01096 <span class="keywordtype">bool</span> RegressionTest::evalJS(Interpreter &interp, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &filename, <span class="keywordtype">bool</span> ignore_nonexistent) <a name="l01097"></a>01097 { <a name="l01098"></a>01098 <a class="codeRef" href="qstring.html">QString</a> fullSourceName = filename; <a name="l01099"></a>01099 <a class="codeRef" href="qfile.html">QFile</a> sourceFile(fullSourceName); <a name="l01100"></a>01100 <a name="l01101"></a>01101 <span class="keywordflow">if</span> (!sourceFile.open(IO_ReadOnly)) { <a name="l01102"></a>01102 <span class="keywordflow">if</span> (!ignore_nonexistent) { <a name="l01103"></a>01103 fprintf(stderr,<span class="stringliteral">"ERROR reading file %s\n"</span>,fullSourceName.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l01104"></a>01104 m_errors++; <a name="l01105"></a>01105 } <a name="l01106"></a>01106 <span class="keywordflow">return</span> ignore_nonexistent; <a name="l01107"></a>01107 } <a name="l01108"></a>01108 <a name="l01109"></a>01109 <a class="codeRef" href="qtextstream.html">QTextStream</a> stream ( &sourceFile ); <a name="l01110"></a>01110 stream.setEncoding( QTextStream::UnicodeUTF8 ); <a name="l01111"></a>01111 <a class="codeRef" href="qstring.html">QString</a> code = stream.read(); <a name="l01112"></a>01112 sourceFile.close(); <a name="l01113"></a>01113 <a name="l01114"></a>01114 saw_failure = <span class="keyword">false</span>; <a name="l01115"></a>01115 ignore_errors = <span class="keyword">false</span>; <a name="l01116"></a>01116 Completion c = interp.evaluate(UString( code ) ); <a name="l01117"></a>01117 <a name="l01118"></a>01118 <span class="keywordflow">if</span> ( <span class="comment">/*report_result &&*/</span> !ignore_errors) { <a name="l01119"></a>01119 <span class="keywordflow">if</span> (c.complType() == Throw) { <a name="l01120"></a>01120 <a class="codeRef" href="qstring.html">QString</a> errmsg = c.value().toString(interp.globalExec()).qstring(); <a name="l01121"></a>01121 printf( <span class="stringliteral">"ERROR: %s (%s)\n"</span>,filename.<a class="codeRef" href="qstring.html#latin1">latin1</a>(), errmsg.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l01122"></a>01122 m_errors++; <a name="l01123"></a>01123 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01124"></a>01124 } <a name="l01125"></a>01125 } <a name="l01126"></a>01126 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l01127"></a>01127 } <a name="l01128"></a>01128 <a name="l01129"></a>01129 <span class="keyword">class </span>GlobalImp : <span class="keyword">public</span> ObjectImp { <a name="l01130"></a>01130 <span class="keyword">public</span>: <a name="l01131"></a>01131 <span class="keyword">virtual</span> UString className()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"global"</span>; } <a name="l01132"></a>01132 }; <a name="l01133"></a>01133 <a name="l01134"></a>01134 RegressionTest::CheckResult RegressionTest::checkOutput(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &againstFilename) <a name="l01135"></a>01135 { <a name="l01136"></a>01136 <a class="codeRef" href="qstring.html">QString</a> absFilename = <a class="codeRef" href="qfileinfo.html">QFileInfo</a>(m_baseDir + <span class="stringliteral">"/baseline/"</span> + againstFilename).<a class="codeRef" href="qfileinfo.html#absFilePath">absFilePath</a>(); <a name="l01137"></a>01137 <span class="keywordflow">if</span> ( svnIgnored( absFilename ) ) { <a name="l01138"></a>01138 m_known_failures = NoFailure; <a name="l01139"></a>01139 <span class="keywordflow">return</span> Ignored; <a name="l01140"></a>01140 } <a name="l01141"></a>01141 <a name="l01142"></a>01142 CheckResult result = Success; <a name="l01143"></a>01143 <a name="l01144"></a>01144 <span class="comment">// compare result to existing file</span> <a name="l01145"></a>01145 <a class="codeRef" href="qstring.html">QString</a> outputFilename = <a class="codeRef" href="qfileinfo.html">QFileInfo</a>(m_outputDir + <span class="stringliteral">"/"</span> + againstFilename).<a class="codeRef" href="qfileinfo.html#absFilePath">absFilePath</a>(); <a name="l01146"></a>01146 <span class="keywordtype">bool</span> kf = <span class="keyword">false</span>; <a name="l01147"></a>01147 <span class="keywordflow">if</span> ( m_known_failures & AllFailure ) <a name="l01148"></a>01148 kf = <span class="keyword">true</span>; <a name="l01149"></a>01149 <span class="keywordflow">if</span> ( kf ) <a name="l01150"></a>01150 outputFilename += <span class="stringliteral">"-KF"</span>; <a name="l01151"></a>01151 <a name="l01152"></a>01152 <span class="keywordflow">if</span> ( m_genOutput ) <a name="l01153"></a>01153 outputFilename = absFilename; <a name="l01154"></a>01154 <a name="l01155"></a>01155 <span class="comment">// get existing content</span> <a name="l01156"></a>01156 <a class="codeRef" href="qstring.html">QString</a> data; <a name="l01157"></a>01157 <span class="keywordflow">if</span> (m_outputCustomised) { <a name="l01158"></a>01158 data = m_outputString; <a name="l01159"></a>01159 } <span class="keywordflow">else</span> { <a name="l01160"></a>01160 data = m_part->text(); <a name="l01161"></a>01161 } <a name="l01162"></a>01162 <a name="l01163"></a>01163 <a class="codeRef" href="qfile.html">QFile</a> file(absFilename); <a name="l01164"></a>01164 <span class="keywordflow">if</span> (file.open(IO_ReadOnly)) { <a name="l01165"></a>01165 <a class="codeRef" href="qtextstream.html">QTextStream</a> stream ( &file ); <a name="l01166"></a>01166 stream.setEncoding( QTextStream::UnicodeUTF8 ); <a name="l01167"></a>01167 <a name="l01168"></a>01168 <a class="codeRef" href="qstring.html">QString</a> fileData = stream.read(); <a name="l01169"></a>01169 <a name="l01170"></a>01170 result = ( fileData == data ) ? Success : Failure; <a name="l01171"></a>01171 <span class="keywordflow">if</span> ( !m_genOutput && result == Success && !m_keepOutput ) { <a name="l01172"></a>01172 ::unlink( <a class="codeRef" href="qfile.html#encodeName">QFile::encodeName</a>( outputFilename ) ); <a name="l01173"></a>01173 <span class="keywordflow">return</span> Success; <a name="l01174"></a>01174 } <a name="l01175"></a>01175 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!m_genOutput) { <a name="l01176"></a>01176 fprintf(stderr, <span class="stringliteral">"Error reading file %s\n"</span>, absFilename.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l01177"></a>01177 result = Failure; <a name="l01178"></a>01178 } <a name="l01179"></a>01179 <a name="l01180"></a>01180 <span class="comment">// generate result file</span> <a name="l01181"></a>01181 createMissingDirs( outputFilename ); <a name="l01182"></a>01182 <a class="codeRef" href="qfile.html">QFile</a> file2(outputFilename); <a name="l01183"></a>01183 <span class="keywordflow">if</span> (!file2.open(IO_WriteOnly)) { <a name="l01184"></a>01184 fprintf(stderr,<span class="stringliteral">"Error writing to file %s\n"</span>,outputFilename.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l01185"></a>01185 exit(1); <a name="l01186"></a>01186 } <a name="l01187"></a>01187 <a name="l01188"></a>01188 <a class="codeRef" href="qtextstream.html">QTextStream</a> stream2(&file2); <a name="l01189"></a>01189 stream2.setEncoding( QTextStream::UnicodeUTF8 ); <a name="l01190"></a>01190 stream2 << data; <a name="l01191"></a>01191 <span class="keywordflow">if</span> ( m_genOutput ) <a name="l01192"></a>01192 printf(<span class="stringliteral">"Generated %s\n"</span>, outputFilename.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l01193"></a>01193 <a name="l01194"></a>01194 <span class="keywordflow">return</span> result; <a name="l01195"></a>01195 } <a name="l01196"></a>01196 <a name="l01197"></a>01197 <span class="keywordtype">void</span> RegressionTest::rereadConfig() <a name="l01198"></a>01198 { <a name="l01199"></a>01199 m_baseConfig->setGroup(<span class="stringliteral">"Kate Document Defaults"</span>); <a name="l01200"></a>01200 m_part->config()->readConfig(m_baseConfig); <a name="l01201"></a>01201 m_baseConfig->setGroup(<span class="stringliteral">"Kate View Defaults"</span>); <a name="l01202"></a>01202 m_view->config()->readConfig(m_baseConfig); <a name="l01203"></a>01203 } <a name="l01204"></a>01204 <a name="l01205"></a>01205 <span class="keywordtype">bool</span> RegressionTest::reportResult(CheckResult result, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> & description, <span class="keywordtype">bool</span> *newfail) <a name="l01206"></a>01206 { <a name="l01207"></a>01207 <span class="keywordflow">if</span> ( result == Ignored ) { <a name="l01208"></a>01208 <span class="comment">//printf("IGNORED: ");</span> <a name="l01209"></a>01209 <span class="comment">//printDescription( description );</span> <a name="l01210"></a>01210 <span class="keywordflow">return</span> <span class="keyword">true</span>; <span class="comment">// no error</span> <a name="l01211"></a>01211 } <span class="keywordflow">else</span> <a name="l01212"></a>01212 <span class="keywordflow">return</span> reportResult( result == Success, description, newfail ); <a name="l01213"></a>01213 } <a name="l01214"></a>01214 <a name="l01215"></a>01215 <span class="keywordtype">bool</span> RegressionTest::reportResult(<span class="keywordtype">bool</span> passed, <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> & description, <span class="keywordtype">bool</span> *newfail) <a name="l01216"></a>01216 { <a name="l01217"></a>01217 <span class="keywordflow">if</span> (newfail) *newfail = <span class="keyword">false</span>; <a name="l01218"></a>01218 <a name="l01219"></a>01219 <span class="keywordflow">if</span> (m_genOutput) <a name="l01220"></a>01220 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l01221"></a>01221 <a name="l01222"></a>01222 <a class="codeRef" href="qstring.html">QString</a> filename(m_currentTest + <span class="stringliteral">"-"</span> + description); <a name="l01223"></a>01223 <span class="keywordflow">if</span> (!m_currentCategory.isEmpty()) <a name="l01224"></a>01224 filename = m_currentCategory + <span class="stringliteral">"/"</span> + filename; <a name="l01225"></a>01225 <a name="l01226"></a>01226 <span class="keyword">const</span> <span class="keywordtype">bool</span> oldfailed = m_failureComp && m_failureComp->readNumEntry(filename); <a name="l01227"></a>01227 <span class="keywordflow">if</span> (passed) { <a name="l01228"></a>01228 <span class="keywordflow">if</span> ( m_known_failures & AllFailure ) { <a name="l01229"></a>01229 printf(<span class="stringliteral">"PASS (unexpected!)"</span>); <a name="l01230"></a>01230 m_passes_fail++; <a name="l01231"></a>01231 } <span class="keywordflow">else</span> { <a name="l01232"></a>01232 printf(<span class="stringliteral">"PASS"</span>); <a name="l01233"></a>01233 m_passes_work++; <a name="l01234"></a>01234 } <a name="l01235"></a>01235 <span class="keywordflow">if</span> (oldfailed) { <a name="l01236"></a>01236 printf(<span class="stringliteral">" (new)"</span>); <a name="l01237"></a>01237 m_passes_new++; <a name="l01238"></a>01238 } <a name="l01239"></a>01239 <span class="keywordflow">if</span> (m_failureSave) <a name="l01240"></a>01240 m_failureSave->deleteEntry(filename); <a name="l01241"></a>01241 } <a name="l01242"></a>01242 <span class="keywordflow">else</span> { <a name="l01243"></a>01243 <span class="keywordflow">if</span> ( m_known_failures & AllFailure ) { <a name="l01244"></a>01244 printf(<span class="stringliteral">"FAIL (known)"</span>); <a name="l01245"></a>01245 m_failures_fail++; <a name="l01246"></a>01246 passed = <span class="keyword">true</span>; <span class="comment">// we knew about it</span> <a name="l01247"></a>01247 } <span class="keywordflow">else</span> { <a name="l01248"></a>01248 printf(<span class="stringliteral">"FAIL"</span>); <a name="l01249"></a>01249 m_failures_work++; <a name="l01250"></a>01250 } <a name="l01251"></a>01251 <span class="keywordflow">if</span> (!oldfailed && m_failureComp) { <a name="l01252"></a>01252 printf(<span class="stringliteral">" (new)"</span>); <a name="l01253"></a>01253 m_failures_new++; <a name="l01254"></a>01254 <span class="keywordflow">if</span> (newfail) *newfail = <span class="keyword">true</span>; <a name="l01255"></a>01255 } <a name="l01256"></a>01256 <span class="keywordflow">if</span> (m_failureSave) <a name="l01257"></a>01257 m_failureSave->writeEntry(filename, 1); <a name="l01258"></a>01258 } <a name="l01259"></a>01259 printf(<span class="stringliteral">": "</span>); <a name="l01260"></a>01260 <a name="l01261"></a>01261 printDescription( description ); <a name="l01262"></a>01262 <span class="keywordflow">return</span> passed; <a name="l01263"></a>01263 } <a name="l01264"></a>01264 <a name="l01265"></a>01265 <span class="keywordtype">void</span> RegressionTest::printDescription(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a>& description) <a name="l01266"></a>01266 { <a name="l01267"></a>01267 <span class="keywordflow">if</span> (!m_currentCategory.isEmpty()) <a name="l01268"></a>01268 printf(<span class="stringliteral">"%s/"</span>, m_currentCategory.latin1()); <a name="l01269"></a>01269 <a name="l01270"></a>01270 printf(<span class="stringliteral">"%s"</span>, m_currentTest.latin1()); <a name="l01271"></a>01271 <a name="l01272"></a>01272 <span class="keywordflow">if</span> (!description.<a class="codeRef" href="qstring.html#isEmpty">isEmpty</a>()) { <a name="l01273"></a>01273 <a class="codeRef" href="qstring.html">QString</a> desc = description; <a name="l01274"></a>01274 desc.<a class="codeRef" href="qstring.html#replace">replace</a>( <span class="charliteral">'\n'</span>, <span class="charliteral">' '</span> ); <a name="l01275"></a>01275 printf(<span class="stringliteral">" [%s]"</span>, desc.<a class="codeRef" href="qstring.html#latin1">latin1</a>()); <a name="l01276"></a>01276 } <a name="l01277"></a>01277 <a name="l01278"></a>01278 printf(<span class="stringliteral">"\n"</span>); <a name="l01279"></a>01279 fflush(stdout); <a name="l01280"></a>01280 } <a name="l01281"></a>01281 <a name="l01282"></a>01282 <span class="keywordtype">void</span> RegressionTest::createMissingDirs(<span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> & filename) <a name="l01283"></a>01283 { <a name="l01284"></a>01284 <a class="codeRef" href="qfileinfo.html">QFileInfo</a> dif(filename); <a name="l01285"></a>01285 <a class="codeRef" href="qfileinfo.html">QFileInfo</a> dirInfo( dif.dirPath() ); <a name="l01286"></a>01286 <span class="keywordflow">if</span> (dirInfo.exists()) <a name="l01287"></a>01287 <span class="keywordflow">return</span>; <a name="l01288"></a>01288 <a name="l01289"></a>01289 <a class="codeRef" href="qstringlist.html">QStringList</a> pathComponents; <a name="l01290"></a>01290 <a class="codeRef" href="qfileinfo.html">QFileInfo</a> parentDir = dirInfo; <a name="l01291"></a>01291 pathComponents.prepend(parentDir.<a class="codeRef" href="qfileinfo.html#absFilePath">absFilePath</a>()); <a name="l01292"></a>01292 <span class="keywordflow">while</span> (!parentDir.<a class="codeRef" href="qfileinfo.html#exists">exists</a>()) { <a name="l01293"></a>01293 <a class="codeRef" href="qstring.html">QString</a> parentPath = parentDir.<a class="codeRef" href="qfileinfo.html#absFilePath">absFilePath</a>(); <a name="l01294"></a>01294 <span class="keywordtype">int</span> slashPos = parentPath.<a class="codeRef" href="qstring.html#findRev">findRev</a>(<span class="charliteral">'/'</span>); <a name="l01295"></a>01295 <span class="keywordflow">if</span> (slashPos < 0) <a name="l01296"></a>01296 <span class="keywordflow">break</span>; <a name="l01297"></a>01297 parentPath = parentPath.<a class="codeRef" href="qstring.html#left">left</a>(slashPos); <a name="l01298"></a>01298 pathComponents.prepend(parentPath); <a name="l01299"></a>01299 parentDir = <a class="codeRef" href="qfileinfo.html">QFileInfo</a>(parentPath); <a name="l01300"></a>01300 } <a name="l01301"></a>01301 <span class="keywordflow">for</span> (uint pathno = 1; pathno < pathComponents.count(); pathno++) { <a name="l01302"></a>01302 <span class="keywordflow">if</span> (!<a class="codeRef" href="qfileinfo.html">QFileInfo</a>(pathComponents[pathno]).<a class="codeRef" href="qfileinfo.html#exists">exists</a>() && <a name="l01303"></a>01303 !<a class="codeRef" href="qdir.html">QDir</a>(pathComponents[pathno-1]).<a class="codeRef" href="qdir.html#mkdir">mkdir</a>(pathComponents[pathno])) { <a name="l01304"></a>01304 fprintf(stderr,<span class="stringliteral">"Error creating directory %s\n"</span>,pathComponents[pathno].latin1()); <a name="l01305"></a>01305 exit(1); <a name="l01306"></a>01306 } <a name="l01307"></a>01307 } <a name="l01308"></a>01308 } <a name="l01309"></a>01309 <a name="l01310"></a>01310 <span class="keywordtype">void</span> RegressionTest::slotOpenURL(<span class="keyword">const</span> <a class="codeRef" doxygen="kdecore.tag:../../kdecore/html/" href="../../kdecore/html/classKURL.html">KURL</a> &url, <span class="keyword">const</span> <a class="codeRef" doxygen="kparts.tag:../../kparts/html/" href="../../kparts/html/structKParts_1_1URLArgs.html">KParts::URLArgs</a> &args) <a name="l01311"></a>01311 { <a name="l01312"></a>01312 m_part->browserExtension()->setURLArgs( args ); <a name="l01313"></a>01313 <a name="l01314"></a>01314 m_part->openURL(url); <a name="l01315"></a>01315 } <a name="l01316"></a>01316 <a name="l01317"></a>01317 <span class="keywordtype">bool</span> RegressionTest::svnIgnored( <span class="keyword">const</span> <a class="codeRef" href="qstring.html">QString</a> &filename ) <a name="l01318"></a>01318 { <a name="l01319"></a>01319 <a class="codeRef" href="qfileinfo.html">QFileInfo</a> fi( filename ); <a name="l01320"></a>01320 <a class="codeRef" href="qstring.html">QString</a> ignoreFilename = fi.dirPath() + <span class="stringliteral">"/svnignore"</span>; <a name="l01321"></a>01321 <a class="codeRef" href="qfile.html">QFile</a> ignoreFile(ignoreFilename); <a name="l01322"></a>01322 <span class="keywordflow">if</span> (!ignoreFile.open(IO_ReadOnly)) <a name="l01323"></a>01323 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01324"></a>01324 <a name="l01325"></a>01325 <a class="codeRef" href="qtextstream.html">QTextStream</a> ignoreStream(&ignoreFile); <a name="l01326"></a>01326 <a class="codeRef" href="qstring.html">QString</a> line; <a name="l01327"></a>01327 <span class="keywordflow">while</span> (!(line = ignoreStream.readLine()).isNull()) { <a name="l01328"></a>01328 <span class="keywordflow">if</span> ( line == fi.fileName() ) <a name="l01329"></a>01329 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l01330"></a>01330 } <a name="l01331"></a>01331 ignoreFile.close(); <a name="l01332"></a>01332 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l01333"></a>01333 } <a name="l01334"></a>01334 <a name="l01335"></a>01335 <span class="keywordtype">void</span> RegressionTest::resizeTopLevelWidget( <span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h ) <a name="l01336"></a>01336 { <a name="l01337"></a>01337 qApp->mainWidget()->resize( w, h ); <a name="l01338"></a>01338 <span class="comment">// Since we're not visible, this doesn't have an immediate effect, QWidget posts the event</span> <a name="l01339"></a>01339 <a class="codeRef" href="qapplication.html#sendPostedEvents-2">QApplication::sendPostedEvents</a>( 0, QEvent::Resize ); <a name="l01340"></a>01340 } <a name="l01341"></a>01341 <a name="l01342"></a>01342 <span class="preprocessor">#include "test_regression.moc"</span> <a name="l01343"></a>01343 <a name="l01344"></a>01344 <span class="comment">// kate: indent-width 4</span> </pre></div></div> </div> </div></div> </td> </tr> <tr> <td valign="top" id="leftmenu" width="25%"> <a name="navigation"></a> <div class="menu_box"><h2>kate</h2> <div class="nav_list"> <ul><li><a href="index.html">Main Page</a></li><li><a href="namespaces.html">Namespace List</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="namespacemembers.html">Namespace Members</a></li><li><a href="functions.html">Class Members</a></li><li><a href="pages.html">Related Pages</a></li></ul> <!-- <h2>Class Picker</h2> <div style="text-align: center;"> <form name="guideform"> <select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> <option value="annotated.html">-- Choose --</option> <option value="classIndenterConfigPage.html">indenterconfigpage</option>, <option value="classKate_1_1Command.html">kate::command</option>, <option value="classKate_1_1CommandExtension.html">kate::commandextension</option>, <option value="classKate_1_1Document.html">kate::document</option>, <option value="classKate_1_1DocumentExt.html">kate::documentext</option>, <option value="classKate_1_1View.html">kate::view</option>, <option value="classKateArbitraryHighlight.html">katearbitraryhighlight</option>, <option value="classKateAttribute.html">kateattribute</option>, <option value="classKateAutoIndent.html">kateautoindent</option>, <option value="classKateBrowserExtension.html">katebrowserextension</option>, <option value="classKateBufBlock.html">katebufblock</option>, <option value="classKateBufBlockList.html">katebufblocklist</option>, <option value="classKateBuffer.html">katebuffer</option>, <option value="classKateCmdShellCompletion.html">katecmdshellcompletion</option>, <option value="classKateCommands_1_1Character.html">katecommands::character</option>, <option value="classKateCommands_1_1CoreCommands.html">katecommands::corecommands</option>, <option value="classKateCommands_1_1Date.html">katecommands::date</option>, <option value="classKateCommands_1_1SedReplace.html">katecommands::sedreplace</option>, <option value="classKateConfig.html">kateconfig</option>, <option value="classKateDocCursor.html">katedoccursor</option>, <option value="classKateJScript.html">katejscript</option>, <option value="classKateModOnHdPrompt.html">katemodonhdprompt</option>, <option value="classKateNormalIndent.html">katenormalindent</option>, <option value="classKateRenderer.html">katerenderer</option>, <option value="classKateReplacePrompt.html">katereplaceprompt</option>, <option value="classKateScrollBar.html">katescrollbar</option>, <option value="classKateSuperCursor.html">katesupercursor</option>, <option value="classKateSuperRange.html">katesuperrange</option>, <option value="classKateSyntaxContextData.html">katesyntaxcontextdata</option>, <option value="classKateSyntaxDocument.html">katesyntaxdocument</option>, <option value="classKateSyntaxModeListItem.html">katesyntaxmodelistitem</option>, <option value="classKateTextCursor.html">katetextcursor</option>, <option value="classKateTextLine.html">katetextline</option>, <option value="classKateUndoGroup.html">kateundogroup</option>, <option value="classKateVarIndent.html">katevarindent</option>, <option value="classKateViewIndentationAction.html">kateviewindentationaction</option>, <option value="classOutputFunction.html">outputfunction</option>, <option value="classOutputObject.html">outputobject</option>, </select> </form> </div> --> </div></div> <div class="menu_box"><h2>API Dox</h2> <div class="nav_list"> <ul> <li><a href="../../arts/html/index.html">arts</a></li><li><a href="../../dcop/html/index.html">dcop</a></li><li><a href="../../dnssd/html/index.html">dnssd</a></li><li><a href="../../interfaces/html/index.html">interfaces</a></li><li> <a href="../../interfaces/kimproxy/interface/html/index.html">interface</a></li><li> <a href="../../interfaces/kimproxy/library/html/index.html">library</a></li><li> <a href="../../interfaces/kspeech/html/index.html">kspeech</a></li><li> <a href="../../interfaces/ktexteditor/html/index.html">ktexteditor</a></li><li><a href="../../kabc/html/index.html">kabc</a></li><li><a href="../../kate/html/index.html">kate</a></li><li><a href="../../kcmshell/html/index.html">kcmshell</a></li><li><a href="../../kdecore/html/index.html">kdecore</a></li><li><a href="../../kded/html/index.html">kded</a></li><li><a href="../../kdefx/html/index.html">kdefx</a></li><li><a href="../../kdeprint/html/index.html">kdeprint</a></li><li><a href="../../kdesu/html/index.html">kdesu</a></li><li><a href="../../kdeui/html/index.html">kdeui</a></li><li><a href="../../kdoctools/html/index.html">kdoctools</a></li><li><a href="../../khtml/html/index.html">khtml</a></li><li><a href="../../kimgio/html/index.html">kimgio</a></li><li><a href="../../kinit/html/index.html">kinit</a></li><li><a href="../../kio/html/index.html">kio</a></li><li> <a href="../../kio/bookmarks/html/index.html">bookmarks</a></li><li> <a href="../../kio/httpfilter/html/index.html">httpfilter</a></li><li> <a href="../../kio/kfile/html/index.html">kfile</a></li><li> <a href="../../kio/kio/html/index.html">kio</a></li><li> <a href="../../kio/kioexec/html/index.html">kioexec</a></li><li> <a href="../../kio/kpasswdserver/html/index.html">kpasswdserver</a></li><li> <a href="../../kio/kssl/html/index.html">kssl</a></li><li><a href="../../kioslave/html/index.html">kioslave</a></li><li> <a href="../../kioslave/http/html/index.html">http</a></li><li><a href="../../kjs/html/index.html">kjs</a></li><li><a href="../../kmdi/html/index.html">kmdi</a></li><li> <a href="../../kmdi/kmdi/html/index.html">kmdi</a></li><li><a href="../../knewstuff/html/index.html">knewstuff</a></li><li><a href="../../kparts/html/index.html">kparts</a></li><li><a href="../../kresources/html/index.html">kresources</a></li><li><a href="../../kspell2/html/index.html">kspell2</a></li><li><a href="../../kunittest/html/index.html">kunittest</a></li><li><a href="../../kutils/html/index.html">kutils</a></li><li><a href="../../kwallet/html/index.html">kwallet</a></li><li><a href="../../libkmid/html/index.html">libkmid</a></li><li><a href="../../libkscreensaver/html/index.html">libkscreensaver</a></li> </ul></div></div> </td> </tr> </table> <span class="doNotDisplay"> <a href="http://www.kde.org/" accesskey="8">KDE Home</a> | <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> | <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a> </span> <div style="height: 8px"></div> <div id="footer"> <div id="footer_left"> Maintained by <a href="mailto:groot@kde.org">Adriaan de Groot</a> and <a href="mailto:winter@kde.org">Allen Winter</a>. <br/> KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div> <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div> </div> <!-- WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL BE BLOCKED INSTANTLY AND PERMANENTLY! <a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a> WARNING END --> </body> </html>