summaryrefslogtreecommitdiffstats
path: root/tests/auto/compilerwarnings
diff options
context:
space:
mode:
authorMarius Storm-Olsen <marius.storm-olsen@nokia.com>2009-08-06 12:45:51 (GMT)
committerMarius Storm-Olsen <marius.storm-olsen@nokia.com>2009-08-06 12:50:08 (GMT)
commitea181f7fa681815f27b633ba0b3b0c2754c1a753 (patch)
tree8ed981aaf40255d7bf64fc9be8b9b3431de1fe12 /tests/auto/compilerwarnings
parent0d57c5111236c06ace5b2759ddb4c63749a057da (diff)
downloadQt-ea181f7fa681815f27b633ba0b3b0c2754c1a753.zip
Qt-ea181f7fa681815f27b633ba0b3b0c2754c1a753.tar.gz
Qt-ea181f7fa681815f27b633ba0b3b0c2754c1a753.tar.bz2
Use QFile instead of QTemporaryFile in compilerwarning testcase
QTemporaryFile on Windows doesn't open the file as a sharable, and doens't close the file when you call .close(). So the testcase fails on Windows with a Sharing Violation when the compiler tries to compile the file. By switching to QFile we can at least close the file before letting the compiler chew on it, and remove it at the end when the testcase is done. Open the file with Truncate, in case the testcase fails to remove the file. Reviewed-by: trustme
Diffstat (limited to 'tests/auto/compilerwarnings')
-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 2f5cf6c..74b7b06 100644
--- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
+++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp
@@ -138,10 +138,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);
@@ -152,6 +153,7 @@ void tst_CompilerWarnings::warnings()
out << in.readAll();
}
}
+ tmpQSourceFile.close();
QVERIFY2(openResult, "Need resource temporary \"test.cpp\"");
QStringList args;
@@ -228,8 +230,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
@@ -243,6 +245,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)