From cd58abb1db7f7dadae515e6aa7ec75b8d23b503d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Feb 2017 13:57:55 -0800 Subject: 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 --- tests/auto/corelib/io/qdir/tst_qdir.cpp | 65 ++++++++++++--------------------- 1 file changed, 24 insertions(+), 41 deletions(-) (limited to 'tests/auto/corelib/io') 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("path"); QTest::addColumn("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("path"); - QTest::addColumn("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("path"); -- cgit v1.2.3 From 329385a5d53f7c20d25b8b492acdd45a5c5ff194 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 9 Jan 2017 11:23:10 +0100 Subject: Build examples and tests only if their requirements are met If the respective modules aren't available we cannot build the tests and examples. We drop the qtConfig(opengl) requirement for the opengl examples as a, we would need to make the QtGui configuration available for that to work, and b, we should not add too much detail to the tests and examples build configurations. Checking each test and example for every feature it uses would be too much. Task-number: QTBUG-57255 Change-Id: Ifb043c81ec9e5c487765297bd65704812cd281fc Reviewed-by: Oswald Buddenhagen --- tests/auto/corelib/io/io.pro | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tests/auto/corelib/io') diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index 5e20f5de5c..ec2c803012 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -49,6 +49,11 @@ SUBDIRS=\ qprocess \ qtextstream +!qtHaveModule(concurrent): SUBDIRS -= \ + qdebug \ + qlockfile \ + qurl + !qtConfig(private_tests): SUBDIRS -= \ qabstractfileengine \ qfileinfo \ -- cgit v1.2.3