From 4672ff71c5c02b13b6435594cc55638d428053ab Mon Sep 17 00:00:00 2001
From: aavit Clear all baselines (They will be recreated by the next run)
"
- "Command output: %2
").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 << "\nTest function: " << testFunction << "
\n";
out << "
Let these mismatching images be the new baselines for this testfunction
\n\n"; out << "image info | \n" @@ -207,7 +211,7 @@ void Report::writeFunctionResults(const ImageItemList &list) out << "
Mismatch reported
\n" << "Baseline Info\n" +#if 0 << "
\n" + << "&newBaseline=" << rendered << "&url=" << pageUrl << "\">Let this be the new baseline\n" +#else + << "\n" +#endif << "\n" << "