summaryrefslogtreecommitdiffstats
path: root/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/compilerwarnings/tst_compilerwarnings.cpp')
-rw-r--r--tests/auto/compilerwarnings/tst_compilerwarnings.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
index d5fef1bfc6..cf2c76de8e 100644
--- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
+++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
@@ -142,10 +142,11 @@ void tst_CompilerWarnings::warnings()
}
static QString tmpSourceFile;
bool openResult = true;
- QString templatePath = QDir::temp().absoluteFilePath("XXXXXX-test.cpp");
- QTemporaryFile tmpQSourceFile(templatePath);
+ const QString tmpBaseName("XXXXXX-test.cpp");
+ QString templatePath = QDir::temp().absoluteFilePath(tmpBaseName);
+ QFile tmpQSourceFile(templatePath);
if (tmpSourceFile.isEmpty()) {
- tmpQSourceFile.open();
+ tmpQSourceFile.open(QIODevice::ReadWrite | QIODevice::Truncate);
tmpSourceFile = tmpQSourceFile.fileName();
QFile cppSource(":/test.cpp");
bool openResult = cppSource.open(QIODevice::ReadOnly);
@@ -156,6 +157,7 @@ void tst_CompilerWarnings::warnings()
out << in.readAll();
}
}
+ tmpQSourceFile.close();
QVERIFY2(openResult, "Need resource temporary \"test.cpp\"");
QStringList args;
@@ -232,8 +234,8 @@ void tst_CompilerWarnings::warnings()
#ifdef Q_CC_MSVC
QString errs = QString::fromLocal8Bit(proc.readAllStandardOutput().constData());
- if (errs.startsWith(tmpSourceFile))
- errs = errs.mid(10);
+ if (errs.startsWith(tmpBaseName))
+ errs = errs.mid(tmpBaseName.size()).simplified();;
#else
QString errs = QString::fromLocal8Bit(proc.readAllStandardError().constData());
#endif
@@ -247,6 +249,8 @@ void tst_CompilerWarnings::warnings()
}
QCOMPARE(errList.count(), 0); // verbose info how many lines of errors in output
QVERIFY(errs.isEmpty());
+
+ tmpQSourceFile.remove();
}
QTEST_APPLESS_MAIN(tst_CompilerWarnings)