summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-02-16 13:57:55 -0800
committerThiago Macieira <thiago.macieira@intel.com>2017-03-22 06:40:59 +0000
commitcd58abb1db7f7dadae515e6aa7ec75b8d23b503d (patch)
tree1c7f5c19ac12c5c3d4eac1b0cbf8e30ff6c61452 /tests
parent524f39db899d68e0ef90184a268eb75ad4ac216e (diff)
Autotest: make tst_QDir more reliable on tests being run out of order
mkdir(data2) depended on mkdir(data1) being run before, or it would fail. In addition, the rmdir() test required the equivalent mkdir() test being run before. So drop these annoying dependencies and make the tests cleaner by having clear separation of the test data and merging the two tests into one The entryList() test still depends on the testdir being clean: it will fail if mkdirRmdir() previously failed. Change-Id: Iaddbecfbba5441c8b2e4fffd14a3e35972d2a3d8 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp65
1 files changed, 24 insertions, 41 deletions
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 6232ce4c66..5a46c1159e 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -99,14 +99,11 @@ private slots:
void entryListWithSymLinks();
- void mkdir_data();
- void mkdir();
+ void mkdirRmdir_data();
+ void mkdirRmdir();
void makedirReturnCode();
- void rmdir_data();
- void rmdir();
-
void removeRecursively_data();
void removeRecursively();
void removeRecursivelyFailure();
@@ -339,26 +336,29 @@ void tst_QDir::setPath()
QCOMPARE(shared.entryList(), entries2);
}
-void tst_QDir::mkdir_data()
+void tst_QDir::mkdirRmdir_data()
{
QTest::addColumn<QString>("path");
QTest::addColumn<bool>("recurse");
QStringList dirs;
- dirs << QDir::currentPath() + "/testdir/one/two/three"
- << QDir::currentPath() + "/testdir/two"
- << QDir::currentPath() + "/testdir/two/three";
- QTest::newRow("data0") << dirs.at(0) << true;
- QTest::newRow("data1") << dirs.at(1) << false;
- QTest::newRow("data2") << dirs.at(2) << false; // note: requires data1 to have been run!
+ dirs << "testdir/one"
+ << "testdir/two/three/four"
+ << "testdir/../testdir/three";
+ QTest::newRow("plain") << QDir::currentPath() + "/" + dirs.at(0) << false;
+ QTest::newRow("recursive") << QDir::currentPath() + "/" + dirs.at(1) << true;
+ QTest::newRow("with-..") << QDir::currentPath() + "/" + dirs.at(2) << false;
+
+ QTest::newRow("relative-plain") << dirs.at(0) << false;
+ QTest::newRow("relative-recursive") << dirs.at(1) << true;
+ QTest::newRow("relative-with-..") << dirs.at(2) << false;
// Ensure that none of these directories already exist
- QDir dir;
for (int i = 0; i < dirs.count(); ++i)
- dir.rmpath(dirs.at(i));
+ QVERIFY(!QFile::exists(dirs.at(i)));
}
-void tst_QDir::mkdir()
+void tst_QDir::mkdirRmdir()
{
QFETCH(QString, path);
QFETCH(bool, recurse);
@@ -373,6 +373,15 @@ void tst_QDir::mkdir()
//make sure it really exists (ie that mkdir returns the right value)
QFileInfo fi(path);
QVERIFY2(fi.exists() && fi.isDir(), msgDoesNotExist(path).constData());
+
+ if (recurse)
+ QVERIFY(dir.rmpath(path));
+ else
+ QVERIFY(dir.rmdir(path));
+
+ //make sure it really doesn't exist (ie that rmdir returns the right value)
+ fi.refresh();
+ QVERIFY(!fi.exists());
}
void tst_QDir::makedirReturnCode()
@@ -402,32 +411,6 @@ void tst_QDir::makedirReturnCode()
f.remove();
}
-void tst_QDir::rmdir_data()
-{
- QTest::addColumn<QString>("path");
- QTest::addColumn<bool>("recurse");
-
- QTest::newRow("data0") << QDir::currentPath() + "/testdir/one/two/three" << true;
- QTest::newRow("data1") << QDir::currentPath() + "/testdir/two/three" << false;
- QTest::newRow("data2") << QDir::currentPath() + "/testdir/two" << false;
-}
-
-void tst_QDir::rmdir()
-{
- QFETCH(QString, path);
- QFETCH(bool, recurse);
-
- QDir dir;
- if (recurse)
- QVERIFY(dir.rmpath(path));
- else
- QVERIFY(dir.rmdir(path));
-
- //make sure it really doesn't exist (ie that rmdir returns the right value)
- QFileInfo fi(path);
- QVERIFY(!fi.exists());
-}
-
void tst_QDir::removeRecursively_data()
{
QTest::addColumn<QString>("path");