From 0b63c90f5f4f5d1948e63c12f8b9b3395d316809 Mon Sep 17 00:00:00 2001 From: aavit Date: Fri, 19 Nov 2010 14:51:40 +0100 Subject: Added command to clear all baselines --- tests/arthur/baselineserver/src/baselineserver.cpp | 42 ++++------------------ tests/arthur/baselineserver/src/baselineserver.h | 3 +- tests/arthur/baselineserver/src/htmlpage.cpp | 26 ++++++-------- 3 files changed, 18 insertions(+), 53 deletions(-) diff --git a/tests/arthur/baselineserver/src/baselineserver.cpp b/tests/arthur/baselineserver/src/baselineserver.cpp index 7679f13..416b58f 100644 --- a/tests/arthur/baselineserver/src/baselineserver.cpp +++ b/tests/arthur/baselineserver/src/baselineserver.cpp @@ -51,6 +51,7 @@ #include #include #include +#include QString BaselineServer::storage; @@ -349,43 +350,14 @@ QString BaselineHandler::pathForItem(const ImageItem &item, bool isBaseline, boo } -QString BaselineHandler::updateAllBaselines(const QString &host, const QString &id, - const QString &engine, const QString &format) +QString BaselineHandler::clearAllBaselines(const QString &context) { -#if 0 - QString basePath(BaselineServer::storagePath()); - QString srcDir(basePath + host + QLC('/') + itemSubPath(engine, format, false) + id); - QString dstDir(basePath + host + QLC('/') + itemSubPath(engine, format)); - - QDir dir(srcDir); - QStringList nameFilter; - nameFilter << "*.metadata" << "*.png"; - QStringList fileList = dir.entryList(nameFilter, QDir::Files | QDir::NoDotAndDotDot); - - // remove the generated _fuzzycompared.png and _compared.png files from the list - QMutableStringListIterator it(fileList); - while (it.hasNext()) { - it.next(); - if (it.value().endsWith(QLS("compared.png"))) - it.remove(); - } + QDirIterator it(BaselineServer::storagePath() + QLC('/') + context, + QStringList() << QLS("*.png") << QLS("*.metadata")); + while (it.hasNext()) + QFile::remove(it.next()); - QString res; - QProcess proc; - proc.setWorkingDirectory(srcDir); - proc.setProcessChannelMode(QProcess::MergedChannels); - proc.start(QLS("cp"), QStringList() << QLS("-f") << fileList << dstDir); - proc.waitForFinished(); - if (proc.exitCode() == 0) - res = QLS("Successfully updated baseline for all failed tests."); - else - res = QString("Error updating baseline: %1
" - "Command output:
%2
").arg(proc.errorString(), proc.readAll().constData()); - - return res; -#else - return QString(); -#endif + return QLS("All baselines cleared from context ") + context; } QString BaselineHandler::updateSingleBaseline(const QString &oldBaseline, const QString &newBaseline) diff --git a/tests/arthur/baselineserver/src/baselineserver.h b/tests/arthur/baselineserver/src/baselineserver.h index d49aedb..c5cb45e 100644 --- a/tests/arthur/baselineserver/src/baselineserver.h +++ b/tests/arthur/baselineserver/src/baselineserver.h @@ -100,8 +100,7 @@ public: BaselineHandler(int socketDescriptor = -1); void testPathMapping(); - static QString updateAllBaselines(const QString &host, const QString &id, - const QString &engine, const QString &format); + static QString clearAllBaselines(const QString &context); static QString updateSingleBaseline(const QString &oldBaseline, const QString &newBaseline); static QString blacklistTest(const QString &context, const QString &itemId, bool removeFromBlacklist = false); diff --git a/tests/arthur/baselineserver/src/htmlpage.cpp b/tests/arthur/baselineserver/src/htmlpage.cpp index f75da88..fdbdfb8 100644 --- a/tests/arthur/baselineserver/src/htmlpage.cpp +++ b/tests/arthur/baselineserver/src/htmlpage.cpp @@ -89,19 +89,16 @@ void HTMLPage::writeHeader(const ImageItem &item) out.setDevice(&file); out << "

Lancelot results from run " << id << "

\n\n"; - out << "

Platform Info:

\n"; + out << "

Platform Info:

\n"; out << "\n"; foreach (QString key, plat.keys()) out << "\n"; - out << "
" << key << "" << plat.value(key) << "
\n"; - -#if 0 - out << "

Update all baselines
"; -#endif - out << "\n" + out << "

\n\n"; + + out << "

Clear all baselines

(They will be recreated by the next run)

\n\n"; + + out << "

\n" "\n" "\n" "\n" @@ -114,7 +111,7 @@ void HTMLPage::writeHeader(const ImageItem &item) void HTMLPage::writeFooter() { - out << "
ScriptBaseline
\n\n"; + out << "

\n\n"; } @@ -207,11 +204,8 @@ void HTMLPage::handleCGIQuery(const QString &query) if (command == QLS("updateSingleBaseline")) { s << BaselineHandler::updateSingleBaseline(cgiUrl.queryItemValue(QLS("oldBaseline")), cgiUrl.queryItemValue(QLS("newBaseline"))); - } else if (command == QLS("updateAllBaselines")) { - s << BaselineHandler::updateAllBaselines(cgiUrl.queryItemValue(QLS("host")), - cgiUrl.queryItemValue(QLS("id")), - cgiUrl.queryItemValue(QLS("engine")), - cgiUrl.queryItemValue(QLS("format"))); + } else if (command == QLS("clearAllBaselines")) { + s << BaselineHandler::clearAllBaselines(cgiUrl.queryItemValue(QLS("context"))); } else if (command == QLS("blacklist")) { // blacklist a test s << BaselineHandler::blacklistTest(cgiUrl.queryItemValue(QLS("context")), -- cgit v0.12