summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-11-23 12:25:17 +0100
committerUlf Hermann <ulf.hermann@qt.io>2017-02-27 15:44:46 +0000
commit44af54419eaceb27bb729717d6363917fd6bb819 (patch)
treeb111875dd8cb8ff653cb0e27cfa766933ca6d589 /tests/auto/corelib/io
parent85b30fda7ceccecfd3938703979b3431bdedc9a2 (diff)
Properly use the "process" feature
Replace all QT_NO_PROCESS with QT_CONFIG(process), define it in qconfig-bootstrapped.h, add QT_REQUIRE_CONFIG(process) to the qprocess headers, exclude the sources from compilation when switched off, guard header inclusions in places where compilation without QProcess seems supported, drop some unused includes, and fix some tests that were apparently designed to work with QT_NO_PROCESS but failed to. Change-Id: Ieceea2504dea6fdf43b81c7c6b65c547b01b9714 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/io.pro8
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp4
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp14
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp28
-rw-r--r--tests/auto/corelib/io/qprocess/testForwarding/main.cpp2
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp13
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp11
7 files changed, 35 insertions, 45 deletions
diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro
index 0542833456..5e20f5de5c 100644
--- a/tests/auto/corelib/io/io.pro
+++ b/tests/auto/corelib/io/io.pro
@@ -56,12 +56,14 @@ SUBDIRS=\
qurlinternal \
qloggingregistry
+!qtConfig(process): SUBDIRS -= \
+ qprocess \
+ qprocess-noapplication \
+ qprocessenvironment
+
win32:!qtConfig(private_tests): SUBDIRS -= \
qfilesystementry
winrt: SUBDIRS -= \
- qprocess \
- qprocess-noapplication \
- qprocessenvironment \
qstorageinfo \
qwinoverlappedionotifier
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index c3774997e9..6232ce4c66 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -852,7 +852,7 @@ void tst_QDir::entryList()
void tst_QDir::entryListTimedSort()
{
-#ifndef QT_NO_PROCESS
+#if QT_CONFIG(process)
const QString touchBinary = "/bin/touch";
if (!QFile::exists(touchBinary))
QSKIP("/bin/touch not found");
@@ -886,7 +886,7 @@ void tst_QDir::entryListTimedSort()
QCOMPARE(actual.last(), aFileInfo.fileName());
#else
QSKIP("This test requires QProcess support.");
-#endif // QT_NO_PROCESS
+#endif // QT_CONFIG(process)
}
void tst_QDir::entryListSimple_data()
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 34ad2813b0..8595c048b2 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -50,7 +50,9 @@ QT_END_NAMESPACE
#if !defined(QT_NO_NETWORK)
#include <QHostInfo>
#endif
-#include <QProcess>
+#if QT_CONFIG(process)
+# include <QProcess>
+#endif
#ifdef Q_OS_WIN
# include <qt_windows.h>
#else
@@ -884,7 +886,7 @@ void tst_QFile::readAllBuffer()
QFile::remove(fileName);
}
-#ifndef QT_NO_PROCESS
+#if QT_CONFIG(process)
class StdinReaderProcessGuard { // Ensure the stdin reader process is stopped on destruction.
Q_DISABLE_COPY(StdinReaderProcessGuard)
@@ -908,11 +910,11 @@ public:
private:
QProcess *m_process;
};
-#endif // !QT_NO_PROCESS
+#endif // QT_CONFIG(process)
void tst_QFile::readAllStdin()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll);
#else
QByteArray lotsOfData(1024, '@'); // 10 megs
@@ -935,7 +937,7 @@ void tst_QFile::readAllStdin()
void tst_QFile::readLineStdin()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll);
#else
QByteArray lotsOfData(1024, '@'); // 10 megs
@@ -976,7 +978,7 @@ void tst_QFile::readLineStdin()
void tst_QFile::readLineStdin_lineByLine()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll);
#else
for (int i = 0; i < 2; ++i) {
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index b21701f341..a13ff0358a 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -72,7 +72,7 @@ void tst_QLockFile::initTestCase()
{
#if defined(Q_OS_ANDROID)
QSKIP("This test requires deploying and running external console applications");
-#elif defined(QT_NO_PROCESS)
+#elif !QT_CONFIG(process)
QSKIP("This test requires QProcess support");
#else
QVERIFY2(dir.isValid(), qPrintable(dir.errorString()));
@@ -80,7 +80,7 @@ void tst_QLockFile::initTestCase()
QString testdata_dir = QFileInfo(QFINDTESTDATA("qlockfiletesthelper")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
m_helperApp = "qlockfiletesthelper/qlockfile_test_helper";
-#endif // !QT_NO_PROCESS
+#endif // QT_CONFIG(process)
}
void tst_QLockFile::lockUnlock()
@@ -114,7 +114,7 @@ void tst_QLockFile::lockUnlock()
void tst_QLockFile::lockOutOtherProcess()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("This test requires QProcess support");
#else
// Lock
@@ -138,7 +138,7 @@ void tst_QLockFile::lockOutOtherProcess()
QCOMPARE(ret, int(QLockFile::NoError));
// Lock doesn't survive process though (on clean exit)
QVERIFY(!QFile::exists(fileName));
-#endif // !QT_NO_PROCESS
+#endif // QT_CONFIG(process)
}
static QLockFile::LockError tryLockFromThread(const QString &fileName)
@@ -254,7 +254,7 @@ void tst_QLockFile::staleLockFromCrashedProcess_data()
void tst_QLockFile::staleLockFromCrashedProcess()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("This test requires QProcess support");
#else
QFETCH(int, staleLockTime);
@@ -274,12 +274,12 @@ void tst_QLockFile::staleLockFromCrashedProcess()
QVERIFY(secondLock.tryLock());
#endif
QCOMPARE(int(secondLock.error()), int(QLockFile::NoError));
-#endif // !QT_NO_PROCESS
+#endif // QT_CONFIG(process)
}
void tst_QLockFile::staleLockFromCrashedProcessReusedPid()
{
-#if defined(QT_NO_PROCESS)
+#if !QT_CONFIG(process)
QSKIP("This test requires QProcess support");
#elif defined(Q_OS_WINRT) || defined(QT_PLATFORM_UIKIT)
QSKIP("We cannot retrieve information about other processes on this platform.");
@@ -298,12 +298,12 @@ void tst_QLockFile::staleLockFromCrashedProcessReusedPid()
secondLock.setStaleLockTime(0);
QVERIFY(secondLock.tryLock());
QCOMPARE(int(secondLock.error()), int(QLockFile::NoError));
-#endif // !QT_NO_PROCESS
+#endif // QT_CONFIG(process)
}
void tst_QLockFile::staleShortLockFromBusyProcess()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("This test requires QProcess support");
#else
const QString fileName = dir.path() + "/staleLockFromBusyProcess";
@@ -331,12 +331,12 @@ void tst_QLockFile::staleShortLockFromBusyProcess()
proc.waitForFinished();
QVERIFY(secondLock.tryLock());
-#endif // !QT_NO_PROCESS
+#endif // QT_CONFIG(process)
}
void tst_QLockFile::staleLongLockFromBusyProcess()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("This test requires QProcess support");
#else
const QString fileName = dir.path() + "/staleLockFromBusyProcess";
@@ -358,7 +358,7 @@ void tst_QLockFile::staleLongLockFromBusyProcess()
QVERIFY(!secondLock.removeStaleLockFile());
proc.waitForFinished();
-#endif // !QT_NO_PROCESS
+#endif // QT_CONFIG(process)
}
static QString tryStaleLockFromThread(const QString &fileName)
@@ -388,7 +388,7 @@ static QString tryStaleLockFromThread(const QString &fileName)
void tst_QLockFile::staleLockRace()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("This test requires QProcess support");
#else
// Multiple threads notice a stale lock at the same time
@@ -406,7 +406,7 @@ void tst_QLockFile::staleLockRace()
synchronizer.waitForFinished();
foreach (const QFuture<QString> &future, synchronizer.futures())
QVERIFY2(future.result().isEmpty(), qPrintable(future.result()));
-#endif // !QT_NO_PROCESS
+#endif // QT_CONFIG(process)
}
void tst_QLockFile::noPermissions()
diff --git a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp
index d76156219e..b7367ff8c6 100644
--- a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp
+++ b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp
@@ -38,7 +38,6 @@ int main(int argc, char **argv)
if (argc < 3)
return 13;
-#ifndef QT_NO_PROCESS
QProcess process;
QProcess::ProcessChannelMode mode = (QProcess::ProcessChannelMode)atoi(argv[1]);
@@ -69,6 +68,5 @@ int main(int argc, char **argv)
if ((mode == QProcess::ForwardedErrorChannel || mode == QProcess::ForwardedChannels)
&& !process.readAllStandardError().isEmpty())
return 6;
-#endif
return 0;
}
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 3f3533c9a1..82efbdcb2c 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -53,7 +53,6 @@ public slots:
void cleanupTestCase();
void init();
-#ifndef QT_NO_PROCESS
private slots:
void getSetCheck();
void constructing();
@@ -159,26 +158,18 @@ protected slots:
private:
qint64 bytesAvailable;
QTemporaryDir m_temporaryDir;
-#endif //QT_NO_PROCESS
};
void tst_QProcess::initTestCase()
{
-#ifdef QT_NO_PROCESS
- QSKIP("This test requires QProcess support");
-#else
QVERIFY2(m_temporaryDir.isValid(), qPrintable(m_temporaryDir.errorString()));
// chdir to our testdata path and execute helper apps relative to that.
QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessNormal")).absolutePath();
QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir));
-#endif
}
void tst_QProcess::cleanupTestCase()
{
-#ifdef QT_NO_PROCESS
- QSKIP("This test requires QProcess support");
-#endif
}
void tst_QProcess::init()
@@ -186,8 +177,6 @@ void tst_QProcess::init()
bytesAvailable = 0;
}
-#ifndef QT_NO_PROCESS
-
// Testing get/set functions
void tst_QProcess::getSetCheck()
{
@@ -2406,7 +2395,5 @@ void tst_QProcess::processEventsInAReadyReadSlot()
QVERIFY(process.waitForFinished());
}
-#endif //QT_NO_PROCESS
-
QTEST_MAIN(tst_QProcess)
#include "tst_qprocess.moc"
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 7f29e2a7d7..0e423a56ca 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -40,8 +40,9 @@
#include <QTemporaryDir>
#include <QTextStream>
#include <QTextCodec>
-#include <QProcess>
-
+#if QT_CONFIG(process)
+# include <QProcess>
+#endif
#include "../../../network-settings.h"
@@ -1493,7 +1494,7 @@ void tst_QTextStream::pos3LargeFile()
// ------------------------------------------------------------------------------
void tst_QTextStream::readStdin()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll);
#else
QProcess stdinProcess;
@@ -1520,7 +1521,7 @@ void tst_QTextStream::readStdin()
// ------------------------------------------------------------------------------
void tst_QTextStream::readAllFromStdin()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll);
#else
QProcess stdinProcess;
@@ -1541,7 +1542,7 @@ void tst_QTextStream::readAllFromStdin()
// ------------------------------------------------------------------------------
void tst_QTextStream::readLineFromStdin()
{
-#ifdef QT_NO_PROCESS
+#if !QT_CONFIG(process)
QSKIP("No qprocess support", SkipAll);
#else
QProcess stdinProcess;