summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2020-06-14 21:36:56 +0200
committerMilian Wolff <milian.wolff@kdab.com>2020-09-11 10:31:08 +0000
commitf1dc7259cbdc12b94d4ce2395ce0da019c4901f0 (patch)
treeced544d6604c5f31f9db6b8a55daf4526e74f9b8
parent8b458e6ef86aefd6e92a1359eb797ca8d55257cd (diff)
Show the diff between files when the perfdata test fails
Only works when the diff program is available on the system. Change-Id: Id4cd5fe96a1a10b03153900600b3fcb43f755100 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--tests/auto/perfdata/tst_perfdata.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/auto/perfdata/tst_perfdata.cpp b/tests/auto/perfdata/tst_perfdata.cpp
index e1f1f31..208b3ba 100644
--- a/tests/auto/perfdata/tst_perfdata.cpp
+++ b/tests/auto/perfdata/tst_perfdata.cpp
@@ -29,6 +29,7 @@
#include <QtEndian>
#include <QProcess>
#include <QRegularExpression>
+#include <QStandardPaths>
class TestPerfData : public QObject
{
@@ -274,6 +275,12 @@ void TestPerfData::testFiles()
expectedText = QString::fromUtf8(expected.readAll());
}
+ if (actualText != expectedText) {
+ const auto diff = QStandardPaths::findExecutable("diff");
+ if (!diff.isEmpty()) {
+ QProcess::execute(diff, {"-u", expectedOutputFile, actualOutputFile});
+ }
+ }
QCOMPARE(actualText, expectedText);
}