Changeset View
Changeset View
Standalone View
Standalone View
autotests/kconfig_compiler/kconfigcompiler_test.cpp
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | 118 | if (!fileRef.open(QIODevice::ReadOnly | QIODevice::Text)) { | |||
---|---|---|---|---|---|
120 | QFAIL("Can't open file for comparison"); | 120 | QFAIL("Can't open file for comparison"); | ||
121 | } | 121 | } | ||
122 | QString content = file.readAll(); | 122 | QString content = file.readAll(); | ||
123 | QString contentRef = fileRef.readAll(); | 123 | QString contentRef = fileRef.readAll(); | ||
124 | 124 | | |||
125 | if (content != contentRef) { | 125 | if (content != contentRef) { | ||
126 | appendFileDiff(fileRef.fileName(), file.fileName()); | 126 | appendFileDiff(fileRef.fileName(), file.fileName()); | ||
127 | } | 127 | } | ||
128 | // use split('\n') to avoid | 128 | | ||
129 | // the whole output shown inline | | |||
dfaure: Why did you remove this? It's just a more user-friendly version of the QVERIFY on the next line… | |||||
the text was really not friendly, it was a big blob of diff content pasted on screen. Considering that the next line will also fail I replaced this by saving the diff file on disk, this way we can actually look at the file that failed and take the time to understand the error. tcanabrava: the text was really not friendly, it was a big blob of diff content pasted on screen. | |||||
OK, this needs a hint for the person debugging regressions then. Something like QVERIFY2(content == contentRef, "Failure, see foo.diff"); dfaure: OK, this needs a hint for the person debugging regressions then. Something like
QVERIFY2… | |||||
tcanabrava: This is done now within the appendFileDiff function. | |||||
130 | QCOMPARE(content.split('\n'), contentRef.split('\n')); | | |||
131 | QVERIFY(content == contentRef); | 129 | QVERIFY(content == contentRef); | ||
132 | } | 130 | } | ||
133 | 131 | | |||
134 | void KConfigCompiler_Test::testRunning_data() | 132 | void KConfigCompiler_Test::testRunning_data() | ||
135 | { | 133 | { | ||
136 | QTest::addColumn<QString>("testName"); | 134 | QTest::addColumn<QString>("testName"); | ||
137 | 135 | | |||
138 | for (const char **it = testCasesToRun; *it; ++it) { | 136 | for (const char **it = testCasesToRun; *it; ++it) { | ||
Show All 33 Lines | 162 | { | |||
172 | args << QFileInfo(newFile).absoluteFilePath(); | 170 | args << QFileInfo(newFile).absoluteFilePath(); | ||
173 | 171 | | |||
174 | QProcess process; | 172 | QProcess process; | ||
175 | process.start(m_diffExe, args, QIODevice::ReadOnly); | 173 | process.start(m_diffExe, args, QIODevice::ReadOnly); | ||
176 | process.waitForStarted(); | 174 | process.waitForStarted(); | ||
177 | process.waitForFinished(); | 175 | process.waitForFinished(); | ||
178 | if (process.exitCode() == 1) { | 176 | if (process.exitCode() == 1) { | ||
179 | QByteArray out = process.readAllStandardOutput(); | 177 | QByteArray out = process.readAllStandardOutput(); | ||
180 | qDebug() << '\n' << out; | 178 | qDebug() << "Saving diff file for" << oldFile; | ||
179 | QFile diffFile(oldFile + QStringLiteral(".diff")); | ||||
180 | diffFile.open(QIODevice::WriteOnly); | ||||
dfaure: QVERIFY(...) | |||||
I meant QVERIFY2(diffFile.open(...), ...). dfaure: I meant QVERIFY2(diffFile.open(...), ...).
No need to make a separate call to isOpen(). | |||||
tcanabrava: ups :)
| |||||
181 | QVERIFY2(diffFile.isOpen(), qPrintable(QLatin1String("Could not save diff file for") + oldFile)); | ||||
182 | diffFile.write(out); | ||||
181 | } | 183 | } | ||
dfaure: diffFile.write(out); would be simpler than going via QTextStream | |||||
182 | } | 184 | } | ||
dfaure: not needed, the dtor closes |
Why did you remove this? It's just a more user-friendly version of the QVERIFY on the next line, so it can't possibly have failed while the next line passes...