Skip to content

Commit

Permalink
Handle disk full situations by skipping QFile::moveToTrash test
Browse files Browse the repository at this point in the history
If any of the temporary directories and files can't be created, skip the
test. Otherwise, the cleanup routine would recursively delete "/".

Change-Id: I51f908a468be8fd2ebd523ff7ce27a7c78d1b4e2
Fixes: QTBUG-83863
Pick-to: 5.15
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
  • Loading branch information
vohi committed May 7, 2020
1 parent a033c23 commit 9b4b406
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/auto/corelib/io/qfile/tst_qfile.cpp
Expand Up @@ -3677,22 +3677,28 @@ void tst_QFile::moveToTrash_data()
// success cases
{
QTemporaryFile temp;
QVERIFY(temp.open());
if (!temp.open())
QSKIP("Failed to create temporary file!");
QTest::newRow("temporary file") << temp.fileName() << true << true;
}
{
QTemporaryDir tempDir;
if (!tempDir.isValid())
QSKIP("Failed to create temporary directory!");
tempDir.setAutoRemove(false);
QTest::newRow("temporary dir")
<< tempDir.path() + QLatin1Char('/')
<< true << true;
}
{
QTemporaryDir homeDir(QDir::homePath() + QLatin1String("/XXXXXX"));
homeDir.setAutoRemove(false);
if (!homeDir.isValid())
QSKIP("Failed to create temporary directory in $HOME!");
QTemporaryFile homeFile(homeDir.path()
+ QLatin1String("/tst_qfile-XXXXXX"));
homeFile.open();
if (!homeFile.open())
QSKIP("Failed to create temporary file in $HOME");
homeDir.setAutoRemove(false);
QTest::newRow("home file")
<< homeFile.fileName()
<< true << true;
Expand Down

0 comments on commit 9b4b406

Please sign in to comment.