diff options
author | aavit <qt-info@nokia.com> | 2011-01-19 14:31:25 (GMT) |
---|---|---|
committer | aavit <qt-info@nokia.com> | 2011-03-01 10:14:56 (GMT) |
commit | 4672ff71c5c02b13b6435594cc55638d428053ab (patch) | |
tree | 82779df9f622289379fd4fd4cb3efd87eb78faf2 /tests/arthur | |
parent | c0ef39aaf2836ef5988e25a219f9bcbff2319ad2 (diff) | |
download | Qt-4672ff71c5c02b13b6435594cc55638d428053ab.zip Qt-4672ff71c5c02b13b6435594cc55638d428053ab.tar.gz Qt-4672ff71c5c02b13b6435594cc55638d428053ab.tar.bz2 |
Re-added the update-all-baselines command
Diffstat (limited to 'tests/arthur')
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.cpp | 34 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/baselineserver.h | 2 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/report.cpp | 26 | ||||
-rw-r--r-- | tests/arthur/baselineserver/src/report.h | 2 |
4 files changed, 38 insertions, 26 deletions
diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 8aaa8ff..75309a4 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -426,27 +426,25 @@ QString BaselineHandler::clearAllBaselines(const QString &context) return QString(QLS("%1 of %2 baselines cleared from context ")).arg((tot-failed)/2).arg(tot/2) + context; } -QString BaselineHandler::updateSingleBaseline(const QString &oldBaseline, const QString &newBaseline) +QString BaselineHandler::updateBaselines(const QString &context, const QString &mismatchContext, const QString &itemId) { - QString res; - QString basePath(BaselineServer::storagePath() + QLC('/')); - QString srcBase(basePath + newBaseline.left(newBaseline.length() - 3)); - QString dstDir(basePath + oldBaseline.left(oldBaseline.lastIndexOf(QLC('/')))); - - QProcess proc; - proc.setProcessChannelMode(QProcess::MergedChannels); - proc.start(QLS("cp"), QStringList() << QLS("-f") << srcBase + QLS(FileFormat) << srcBase + QLS(MetadataFileExt) << dstDir); - proc.waitForFinished(); - if (proc.exitCode() == 0) - res = QString("Successfully updated '%1'").arg(oldBaseline); - else - res = QString("Error updating baseline: %1<br>" - "Command output: <pre>%2</pre>").arg(proc.errorString(), proc.readAll().constData()); - - return res; + int tot = 0; + int failed = 0; + QString storagePrefix = BaselineServer::storagePath() + QLC('/'); + // If itemId is set, update just that one, otherwise, update all: + QString filter = (itemId.isEmpty() ? QLS("*") : itemId) + QLS("_????."); // Match any checksum. #vulnerable to changes in file naming + QDirIterator it(storagePrefix + mismatchContext, QStringList() << filter + QLS(FileFormat) << filter + QLS(MetadataFileExt)); + while (it.hasNext()) { + tot++; + it.next(); + QString oldFile = storagePrefix + context + QLC('/') + it.fileName(); + QFile::remove(oldFile); // Remove existing baseline file + if (!QFile::copy(it.filePath(), oldFile)) // and replace it with the mismatch + failed++; + } + return QString(QLS("%1 of %2 baselines updated in context %3 from context %4")).arg((tot-failed)/2).arg(tot/2).arg(context, mismatchContext); } - QString BaselineHandler::blacklistTest(const QString &context, const QString &itemId, bool removeFromBlacklist) { QFile file(BaselineServer::storagePath() + QLC('/') + context + QLS("/BLACKLIST")); diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index a5683b2..0f14c8c 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -109,7 +109,7 @@ public: // CGI callbacks: static QString view(const QString &baseline, const QString &rendered, const QString &compared); static QString clearAllBaselines(const QString &context); - static QString updateSingleBaseline(const QString &oldBaseline, const QString &newBaseline); + static QString updateBaselines(const QString &context, const QString &mismatchContext, const QString &itemId); static QString blacklistTest(const QString &context, const QString &itemId, bool removeFromBlacklist = false); private slots: diff --git a/tests/arthur/baselineserver/src/report.cpp b/tests/arthur/baselineserver/src/report.cpp index c85f144..217b92c 100644 --- a/tests/arthur/baselineserver/src/report.cpp +++ b/tests/arthur/baselineserver/src/report.cpp @@ -154,10 +154,14 @@ void Report::writeFunctionResults(const ImageItemList &list) QString testFunction = list.at(0).testFunction; QString pageUrl = BaselineServer::baseUrl() + path; QString ctx = handler->pathForItem(list.at(0), true, false).section(QLC('/'), 0, -2); + QString misCtx = handler->pathForItem(list.at(0), false, false).section(QLC('/'), 0, -2); + out << "\n<p> </p><h3>Test function: " << testFunction << "</h3>\n"; out << "<p><a href=\"/cgi-bin/server.cgi?cmd=clearAllBaselines&context=" << ctx << "&url=" << pageUrl - << "\"><b><big>Clear all baselines</big></b></a></h3> (They will be recreated by the next run)</p>\n\n"; + << "\"><b>Clear all baselines</b></a> for this testfunction (They will be recreated by the next run)</p>\n"; + out << "<p><a href=\"/cgi-bin/server.cgi?cmd=updateAllBaselines&context=" << ctx << "&mismatchContext=" << misCtx << "&url=" << pageUrl + << "\"><b>Let these mismatching images be the new baselines</b></a> for this testfunction</p>\n\n"; out << "<table border=\"2\">\n" "<tr>\n" @@ -176,7 +180,7 @@ void Report::writeFunctionResults(const ImageItemList &list) QString metadata = prefix + QLS(MetadataFileExt); if (item.status == ImageItem::Mismatch) { QString rendered = handler->pathForItem(item, false, false) + QLS(FileFormat); - writeItem(baseline, rendered, item, ctx, metadata); + writeItem(baseline, rendered, item, ctx, misCtx, metadata); } else { out << "<td align=center><a href=\"/" << baseline << "\">image</a> <a href=\"/" << metadata << "\">info</a></td>\n" @@ -207,7 +211,7 @@ void Report::writeFunctionResults(const ImageItemList &list) out << "</table>\n"; } -void Report::writeItem(const QString &baseline, const QString &rendered, const ImageItem &item, const QString &ctx, const QString &metadata) +void Report::writeItem(const QString &baseline, const QString &rendered, const ImageItem &item, const QString &ctx, const QString &misCtx, const QString &metadata) { QString compared = generateCompared(baseline, rendered); QString pageUrl = BaselineServer::baseUrl() + path; @@ -219,8 +223,13 @@ void Report::writeItem(const QString &baseline, const QString &rendered, const I out << "<td align=center>\n" << "<p><span style=\"color:red\">Mismatch reported</span></p>\n" << "<p><a href=\"/" << metadata << "\">Baseline Info</a>\n" +#if 0 << "<p><a href=\"/cgi-bin/server.cgi?cmd=updateSingleBaseline&oldBaseline=" << baseline - << "&newBaseline=" << rendered << "&url=" << pageUrl << "\">Replace baseline with rendered</a></p>\n" + << "&newBaseline=" << rendered << "&url=" << pageUrl << "\">Let this be the new baseline</a></p>\n" +#else + << "<p><a href=\"/cgi-bin/server.cgi?cmd=updateSingleBaseline&context=" << ctx << "&mismatchContext=" << misCtx + << "&itemId=" << item.itemName << "&url=" << pageUrl << "\">Let this be the new baseline</a></p>\n" +#endif << "<p><a href=\"/cgi-bin/server.cgi?cmd=blacklist&context=" << ctx << "&itemId=" << item.itemName << "&url=" << pageUrl << "\">Blacklist this item</a></p>\n" << "<p><a href=\"/cgi-bin/server.cgi?cmd=view&baseline=" << baseline << "&rendered=" << rendered @@ -280,8 +289,13 @@ void Report::handleCGIQuery(const QString &query) cgiUrl.queryItemValue(QLS("compared"))); } else if (command == QLS("updateSingleBaseline")) { - s << BaselineHandler::updateSingleBaseline(cgiUrl.queryItemValue(QLS("oldBaseline")), - cgiUrl.queryItemValue(QLS("newBaseline"))); + s << BaselineHandler::updateBaselines(cgiUrl.queryItemValue(QLS("context")), + cgiUrl.queryItemValue(QLS("mismatchContext")), + cgiUrl.queryItemValue(QLS("itemId"))); + } else if (command == QLS("updateAllBaselines")) { + s << BaselineHandler::updateBaselines(cgiUrl.queryItemValue(QLS("context")), + cgiUrl.queryItemValue(QLS("mismatchContext")), + QString()); } else if (command == QLS("clearAllBaselines")) { s << BaselineHandler::clearAllBaselines(cgiUrl.queryItemValue(QLS("context"))); } else if (command == QLS("blacklist")) { diff --git a/tests/arthur/baselineserver/src/report.h b/tests/arthur/baselineserver/src/report.h index a56aafb..d090886 100644 --- a/tests/arthur/baselineserver/src/report.h +++ b/tests/arthur/baselineserver/src/report.h @@ -67,7 +67,7 @@ public: private: void write(); void writeFunctionResults(const ImageItemList &list); - void writeItem(const QString &baseline, const QString &rendered, const ImageItem &item, const QString &ctx, const QString &metadata); + void writeItem(const QString &baseline, const QString &rendered, const ImageItem &item, const QString &ctx, const QString &misCtx, const QString &metadata); void writeHeader(); void writeFooter(); QString generateCompared(const QString &baseline, const QString &rendered, bool fuzzy = false); |