tst_QTemporaryFile: Run in temporary directory.
The test leaks a file (named qt_...xxx) in QDir::tempPath(). Moreover, when tests fail, it can happen that more files are leaked and subsequent runs do not recover since the check for non-existence of those files fails. Change-Id: Iaea6d09ee7c271903a1b9c63e263c19f9e90bba9 Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
23bed9f820
commit
95f1f6f719
@ -34,6 +34,7 @@
|
||||
#include <QtTest/QtTest>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qstring.h>
|
||||
#include <qtemporarydir.h>
|
||||
#include <qtemporaryfile.h>
|
||||
#include <qfile.h>
|
||||
#include <qdir.h>
|
||||
@ -86,13 +87,15 @@ private slots:
|
||||
void QTBUG_4796();
|
||||
void guaranteeUnique();
|
||||
private:
|
||||
QTemporaryDir m_temporaryDir;
|
||||
QString m_previousCurrent;
|
||||
};
|
||||
|
||||
void tst_QTemporaryFile::initTestCase()
|
||||
{
|
||||
QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
|
||||
m_previousCurrent = QDir::currentPath();
|
||||
QDir::setCurrent(QDir::tempPath());
|
||||
QVERIFY(QDir::setCurrent(m_temporaryDir.path()));
|
||||
|
||||
// For QTBUG_4796
|
||||
QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX"));
|
||||
@ -119,9 +122,6 @@ void tst_QTemporaryFile::initTestCase()
|
||||
|
||||
void tst_QTemporaryFile::cleanupTestCase()
|
||||
{
|
||||
// From QTBUG_4796
|
||||
QVERIFY(QDir().rmdir("test-XXXXXX"));
|
||||
|
||||
QDir::setCurrent(m_previousCurrent);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user