Skip instead of entirely excluding tests with disabled features

Properly QSKIP tests that use disabled QProcess and symlink
features instead of excluding them silently by #ifdef.
Other reason is that moc doesn't respect QT_NO_* defines
in class definition which causes build issues on some
platforms.

Change-Id: I041020f7452f7d36c7ec8a5866a4ba5eb23d1f94
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
This commit is contained in:
Marko Kangas 2015-02-13 13:01:57 +02:00
parent f1b3244ac1
commit bc69fd1dfe
16 changed files with 122 additions and 55 deletions

View File

@ -84,7 +84,7 @@ private slots:
void codecForUtfText_data();
void codecForUtfText();
#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
#if defined(Q_OS_UNIX)
void toLocal8Bit();
#endif
@ -2070,9 +2070,12 @@ void tst_QTextCodec::codecForUtfText()
QVERIFY(codec == 0);
}
#if defined(Q_OS_UNIX) && !defined(QT_NO_PROCESS)
#if defined(Q_OS_UNIX)
void tst_QTextCodec::toLocal8Bit()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QProcess process;
process.start("echo/echo");
QString string(QChar(0x410));
@ -2082,6 +2085,7 @@ void tst_QTextCodec::toLocal8Bit()
process.waitForFinished();
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), 0);
#endif
}
#endif

View File

@ -139,7 +139,7 @@ private slots:
void readAll_data();
void readAll();
void readAllBuffer();
#if !defined(Q_OS_WINCE) && !defined(QT_NO_PROCESS)
#if !defined(Q_OS_WINCE)
void readAllStdin();
void readLineStdin();
void readLineStdin_lineByLine();
@ -868,9 +868,12 @@ void tst_QFile::readAllBuffer()
QFile::remove(fileName);
}
#if !defined(Q_OS_WINCE) && !defined(QT_NO_PROCESS)
#if !defined(Q_OS_WINCE)
void tst_QFile::readAllStdin()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QByteArray lotsOfData(1024, '@'); // 10 megs
QProcess process;
@ -887,11 +890,14 @@ void tst_QFile::readAllStdin()
process.closeWriteChannel();
process.waitForFinished();
QCOMPARE(process.readAll().size(), lotsOfData.size() * 5);
#endif
}
void tst_QFile::readLineStdin()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QByteArray lotsOfData(1024, '@'); // 10 megs
for (int i = 0; i < lotsOfData.size(); ++i) {
if ((i % 32) == 31)
@ -926,10 +932,14 @@ void tst_QFile::readLineStdin()
QCOMPARE(char(array[i]), char('0' + i % 32));
}
}
#endif
}
void tst_QFile::readLineStdin_lineByLine()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
for (int i = 0; i < 2; ++i) {
QProcess process;
process.start(m_stdinProcessDir + QStringLiteral("/stdinprocess"),
@ -949,6 +959,7 @@ void tst_QFile::readLineStdin_lineByLine()
process.closeWriteChannel();
QVERIFY(process.waitForFinished(5000));
}
#endif
}
#endif

View File

@ -219,10 +219,8 @@ private slots:
void fileTimes();
void fileTimes_oldFile();
#ifndef Q_NO_SYMLINKS
void isSymLink_data();
void isSymLink();
#endif
void isHidden_data();
void isHidden();
@ -1206,9 +1204,9 @@ void tst_QFileInfo::fileTimes_oldFile()
#endif
}
#ifndef Q_NO_SYMLINKS
void tst_QFileInfo::isSymLink_data()
{
#ifndef Q_NO_SYMLINKS
QFile::remove("link.lnk");
QFile::remove("brokenlink.lnk");
QFile::remove("dummyfile");
@ -1228,10 +1226,14 @@ void tst_QFileInfo::isSymLink_data()
QTest::newRow("existent file") << m_sourceFile << false << "";
QTest::newRow("link") << "link.lnk" << true << QFileInfo(m_sourceFile).absoluteFilePath();
QTest::newRow("broken link") << "brokenlink.lnk" << true << QFileInfo("dummyfile").absoluteFilePath();
#endif
}
void tst_QFileInfo::isSymLink()
{
#ifdef Q_NO_SYMLINKS
QSKIP("No symlink support", SkipAll);
#else
QFETCH(QString, path);
QFETCH(bool, isSymLink);
QFETCH(QString, linkTarget);
@ -1239,8 +1241,8 @@ void tst_QFileInfo::isSymLink()
QFileInfo fi(path);
QCOMPARE(fi.isSymLink(), isSymLink);
QCOMPARE(fi.symLinkTarget(), linkTarget);
}
#endif
}
void tst_QFileInfo::isHidden_data()
{

View File

@ -187,7 +187,7 @@ private slots:
void pos();
void pos2();
void pos3LargeFile();
#if !defined(Q_OS_WINCE) && !defined(QT_NO_PROCESS)
#if !defined(Q_OS_WINCE)
void readStdin();
void readAllFromStdin();
void readLineFromStdin();
@ -1484,9 +1484,12 @@ void tst_QTextStream::pos3LargeFile()
// ------------------------------------------------------------------------------
// Qt/CE has no stdin/out support for processes
#if !defined(Q_OS_WINCE) && !defined(QT_NO_PROCESS)
#if !defined(Q_OS_WINCE)
void tst_QTextStream::readStdin()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QProcess stdinProcess;
stdinProcess.start("stdinProcess/stdinProcess");
stdinProcess.setReadChannel(QProcess::StandardError);
@ -1505,12 +1508,16 @@ void tst_QTextStream::readStdin()
QCOMPARE(a, 1);
QCOMPARE(b, 2);
QCOMPARE(c, 3);
#endif
}
// ------------------------------------------------------------------------------
// Qt/CE has no stdin/out support for processes
void tst_QTextStream::readAllFromStdin()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QProcess stdinProcess;
stdinProcess.start("readAllStdinProcess/readAllStdinProcess", QIODevice::ReadWrite | QIODevice::Text);
stdinProcess.setReadChannel(QProcess::StandardError);
@ -1523,12 +1530,16 @@ void tst_QTextStream::readAllFromStdin()
QVERIFY(stdinProcess.waitForFinished(5000));
QCOMPARE(stream.readAll(), QString::fromLatin1("hello world\n"));
#endif
}
// ------------------------------------------------------------------------------
// Qt/CE has no stdin/out support for processes
void tst_QTextStream::readLineFromStdin()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QProcess stdinProcess;
stdinProcess.start("readLineStdinProcess/readLineStdinProcess", QIODevice::ReadWrite | QIODevice::Text);
stdinProcess.setReadChannel(QProcess::StandardError);
@ -1544,6 +1555,7 @@ void tst_QTextStream::readLineFromStdin()
stdinProcess.closeWriteChannel();
QVERIFY(stdinProcess.waitForFinished(5000));
#endif
}
#endif

View File

@ -91,9 +91,7 @@ private slots:
void floatProperty();
void qrealProperty();
void property();
#ifndef QT_NO_PROCESS
void recursiveSignalEmission();
#endif
void signalBlocking();
void blockingQueuedConnection();
void childEvents();
@ -2981,9 +2979,11 @@ void tst_QObject::dynamicProperties()
QVERIFY(obj.dynamicPropertyNames().isEmpty());
}
#ifndef QT_NO_PROCESS
void tst_QObject::recursiveSignalEmission()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QProcess proc;
// signalbug helper app should always be next to this test binary
const QString path = QStringLiteral("signalbug/signalbug");
@ -2992,8 +2992,8 @@ void tst_QObject::recursiveSignalEmission()
QVERIFY(proc.waitForFinished());
QVERIFY(proc.exitStatus() == QProcess::NormalExit);
QCOMPARE(proc.exitCode(), 0);
}
#endif
}
void tst_QObject::signalBlocking()
{

View File

@ -74,7 +74,7 @@ private slots:
void removeWhileAttached();
#endif
void emptyMemory();
#if !defined(Q_OS_WIN) && !defined(QT_NO_PROCESS)
#if !defined(Q_OS_WIN)
void readOnly();
#endif
@ -90,10 +90,8 @@ private slots:
void simpleThreadedProducerConsumer();
// with processes
#ifndef QT_NO_PROCESS
void simpleProcessProducerConsumer_data();
void simpleProcessProducerConsumer();
#endif
// extreme cases
void useTooMuchMemory();
@ -457,9 +455,12 @@ void tst_QSharedMemory::emptyMemory()
by writing to data and causing a segfault.
*/
// This test opens a crash dialog on Windows.
#if !defined(Q_OS_WIN) && !defined(QT_NO_PROCESS)
#if !defined(Q_OS_WIN)
void tst_QSharedMemory::readOnly()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
rememberKey("readonly_segfault");
// ### on windows disable the popup somehow
QProcess p;
@ -467,6 +468,7 @@ void tst_QSharedMemory::readOnly()
p.setProcessChannelMode(QProcess::ForwardedChannels);
p.waitForFinished();
QCOMPARE(p.error(), QProcess::Crashed);
#endif
}
#endif
@ -738,15 +740,16 @@ void tst_QSharedMemory::simpleThreadedProducerConsumer()
}
}
#ifndef QT_NO_PROCESS
void tst_QSharedMemory::simpleProcessProducerConsumer_data()
{
#ifndef QT_NO_PROCESS
QTest::addColumn<int>("processes");
int tries = 5;
for (int i = 0; i < tries; ++i) {
QTest::newRow("1 process") << 1;
QTest::newRow("5 processes") << 5;
}
#endif
}
/*!
@ -754,6 +757,9 @@ void tst_QSharedMemory::simpleProcessProducerConsumer_data()
*/
void tst_QSharedMemory::simpleProcessProducerConsumer()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QFETCH(int, processes);
QSKIP("This test is unstable: QTBUG-25655");
@ -797,8 +803,8 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
producer.write("", 1);
producer.waitForBytesWritten();
QVERIFY(producer.waitForFinished(5000));
}
#endif
}
void tst_QSharedMemory::uniqueKey_data()
{

View File

@ -59,7 +59,6 @@ private slots:
void complexacquire();
void release();
#ifndef QT_NO_PROCESS
void basicProcesses();
void processes_data();
@ -69,7 +68,6 @@ private slots:
void undo();
#endif
void initialValue();
#endif // QT_NO_PROCESS
private:
static QString helperBinary();
@ -177,9 +175,11 @@ void tst_QSystemSemaphore::release()
QCOMPARE(sem.errorString(), QString());
}
#ifndef QT_NO_PROCESS
void tst_QSystemSemaphore::basicProcesses()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QSystemSemaphore sem("store", 0, QSystemSemaphore::Create);
QProcess acquire;
@ -198,6 +198,7 @@ void tst_QSystemSemaphore::basicProcesses()
acquire.waitForFinished(HELPERWAITTIME);
release.waitForFinished(HELPERWAITTIME);
QVERIFY(acquire.state() == QProcess::NotRunning);
#endif
}
void tst_QSystemSemaphore::processes_data()
@ -212,6 +213,9 @@ void tst_QSystemSemaphore::processes_data()
void tst_QSystemSemaphore::processes()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QSystemSemaphore sem("store", 1, QSystemSemaphore::Create);
QFETCH(int, processes);
@ -231,12 +235,16 @@ void tst_QSystemSemaphore::processes()
QCOMPARE(consumers.first()->exitCode(), 0);
delete consumers.takeFirst();
}
#endif
}
// This test only checks a system v unix behavior.
#if !defined(Q_OS_WIN) && !defined(QT_POSIX_IPC)
void tst_QSystemSemaphore::undo()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QSystemSemaphore sem("store", 1, QSystemSemaphore::Create);
QStringList acquireArguments = QStringList("acquire");
@ -253,11 +261,15 @@ void tst_QSystemSemaphore::undo()
QVERIFY2(acquire.waitForStarted(), "Could not start helper binary");
acquire.waitForFinished(HELPERWAITTIME);
QVERIFY(acquire.state()== QProcess::NotRunning);
#endif
}
#endif
void tst_QSystemSemaphore::initialValue()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QSystemSemaphore sem("store", 1, QSystemSemaphore::Create);
QStringList acquireArguments = QStringList("acquire");
@ -284,8 +296,8 @@ void tst_QSystemSemaphore::initialValue()
acquire.waitForFinished(HELPERWAITTIME);
release.waitForFinished(HELPERWAITTIME);
QVERIFY(acquire.state()== QProcess::NotRunning);
}
#endif
}
QString tst_QSystemSemaphore::helperBinary()
{

View File

@ -41,7 +41,11 @@
void tst_QMimeDatabase::init()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
const QString mimeDirName = m_globalXdgDir + QStringLiteral("/mime");
runUpdateMimeDatabase(mimeDirName);
QVERIFY(QFile::exists(mimeDirName + QStringLiteral("/mime.cache")));
#endif
}

View File

@ -66,9 +66,7 @@ private slots:
void versions();
void threadUniqueness();
#ifndef QT_NO_PROCESS
void processUniqueness();
#endif
void hash();
@ -325,9 +323,11 @@ void tst_QUuid::threadUniqueness()
qDeleteAll(threads);
}
#ifndef QT_NO_PROCESS
void tst_QUuid::processUniqueness()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QProcess process;
QString processOneOutput;
QString processTwoOutput;
@ -352,8 +352,8 @@ void tst_QUuid::processUniqueness()
// They should be *different*!
QVERIFY(processOneOutput != processTwoOutput);
}
#endif
}
void tst_QUuid::hash()
{

View File

@ -63,9 +63,7 @@ private slots:
void autoDelete();
void adoptedThreads();
void ensureCleanupOrder();
#ifndef QT_NO_PROCESS
void crashOnExit();
#endif
void leakInDestructor();
void resetInDestructor();
void valueBased();
@ -320,14 +318,18 @@ static inline bool runCrashOnExit(const QString &binary, QString *errorMessage)
}
return true;
}
#endif
void tst_QThreadStorage::crashOnExit()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
QString errorMessage;
QVERIFY2(runCrashOnExit(m_crashOnExit, &errorMessage),
qPrintable(errorMessage));
}
#endif
}
// S stands for thread Safe.
class SPointer

View File

@ -134,7 +134,7 @@ private slots:
#endif
void ctor();
#if !defined(Q_OS_WINCE) && !defined(QT_NO_PROCESS)
#if !defined(Q_OS_WINCE)
void emptyCtor();
#endif
void legacyNames();
@ -499,9 +499,14 @@ static inline bool runSysAppTest(const QString &binary,
}
return true;
}
#endif
#if !defined(Q_OS_WINCE)
void tst_QLocale::emptyCtor()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
#define TEST_CTOR(req_lc, exp_str) \
{ \
/* Test constructor without arguments. Needs separate process */ \
@ -570,6 +575,7 @@ void tst_QLocale::emptyCtor()
#endif // Q_OS_BLACKBERRY
#undef TEST_CTOR
#endif
}
#endif

View File

@ -294,10 +294,8 @@ private Q_SLOTS:
void ioPutToFileFromSocket();
void ioPutToFileFromLocalSocket_data();
void ioPutToFileFromLocalSocket();
#ifndef QT_NO_PROCESS
void ioPutToFileFromProcess_data();
void ioPutToFileFromProcess();
#endif
void ioPutToFtpFromFile_data();
void ioPutToFtpFromFile();
void ioPutToHttpFromFile_data();
@ -4276,14 +4274,19 @@ void tst_QNetworkReply::ioPutToFileFromLocalSocket()
}
// Currently no stdin/out supported for Windows CE.
#ifndef QT_NO_PROCESS
void tst_QNetworkReply::ioPutToFileFromProcess_data()
{
#ifndef QT_NO_PROCESS
putToFile_data();
#endif
}
void tst_QNetworkReply::ioPutToFileFromProcess()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
#if defined(Q_OS_WINCE)
QSKIP("Currently no stdin/out supported for Windows CE");
#else
@ -4321,8 +4324,9 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
QByteArray contents = file.readAll();
QCOMPARE(contents, data);
#endif
#endif // QT_NO_PROCESS
}
#endif
void tst_QNetworkReply::ioPutToFtpFromFile_data()
{

View File

@ -67,9 +67,7 @@ private slots:
void sessionClosing_data();
void sessionClosing();
#ifndef QT_NO_PROCESS
void outOfProcessSession();
#endif
void invalidSession();
void repeatedOpenClose_data();
@ -899,9 +897,11 @@ QDebug operator<<(QDebug debug, const QList<QNetworkConfiguration> &list)
// Note: outOfProcessSession requires that at least one configuration is
// at Discovered -state.
#ifndef QT_NO_PROCESS
void tst_QNetworkSession::outOfProcessSession()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
updateConfigurations();
QTest::qWait(2000);
@ -996,8 +996,8 @@ void tst_QNetworkSession::outOfProcessSession()
default:
QSKIP("Lackey failed");
}
}
#endif
}
// A convenience / helper function for testcases. Return the first matching configuration.
// Ignores configurations in other than 'discovered' -state. Returns invalid (QNetworkConfiguration())

View File

@ -88,10 +88,8 @@ private slots:
void threadedConnection_data();
void threadedConnection();
#ifndef QT_NO_PROCESS
void processConnection_data();
void processConnection();
#endif
void longPath();
void waitForDisconnect();
@ -784,7 +782,6 @@ void tst_QLocalSocket::threadedConnection()
}
}
#ifndef QT_NO_PROCESS
void tst_QLocalSocket::processConnection_data()
{
QTest::addColumn<int>("processes");
@ -794,6 +791,7 @@ void tst_QLocalSocket::processConnection_data()
QTest::newRow("30 clients") << 30;
}
#ifndef QT_NO_PROCESS
class ProcessOutputDumper
{
public:
@ -815,12 +813,16 @@ public:
private:
QProcess *process;
};
#endif
/*!
Create external processes that produce and consume.
*/
void tst_QLocalSocket::processConnection()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
#ifdef Q_OS_MAC
QSKIP("The processConnection test is unstable on Mac. See QTBUG-39986.");
#endif
@ -860,8 +862,8 @@ void tst_QLocalSocket::processConnection()
}
producer.waitForFinished(15000);
producerOutputDumper.clear();
}
#endif
}
void tst_QLocalSocket::longPath()
{

View File

@ -96,9 +96,7 @@ private slots:
void setSocketDescriptor();
#endif
void listenWhileListening();
#ifndef QT_NO_PROCESS
void addressReusable();
#endif
void setNewSocketDescriptorBlocking();
#ifndef QT_NO_NETWORKPROXY
void invalidProxy_data();
@ -565,9 +563,11 @@ protected:
#endif // !Q_OS_WINRT
};
#ifndef QT_NO_PROCESS
void tst_QTcpServer::addressReusable()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
#ifdef Q_OS_LINUX
QSKIP("The addressReusable test is unstable on Linux. See QTBUG-39985.");
#endif
@ -616,8 +616,8 @@ void tst_QTcpServer::addressReusable()
QTcpServer server;
QVERIFY(server.listen(QHostAddress::LocalHost, 49199));
}
#endif
}
void tst_QTcpServer::setNewSocketDescriptorBlocking()
{

View File

@ -95,10 +95,8 @@ private slots:
void writeDatagramToNonExistingPeer();
void writeToNonExistingPeer_data();
void writeToNonExistingPeer();
#ifndef QT_NO_PROCESS
void outOfProcessConnectedClientServerTest();
void outOfProcessUnconnectedClientServerTest();
#endif
void zeroLengthDatagram();
void multicastTtlOption_data();
void multicastTtlOption();
@ -937,9 +935,11 @@ void tst_QUdpSocket::writeToNonExistingPeer()
QCOMPARE(int(sConnected.state()), int(QUdpSocket::ConnectedState));
}
#ifndef QT_NO_PROCESS
void tst_QUdpSocket::outOfProcessConnectedClientServerTest()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
#if defined(Q_OS_WINCE)
QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE).");
#endif
@ -996,12 +996,14 @@ void tst_QUdpSocket::outOfProcessConnectedClientServerTest()
QVERIFY(clientProcess.waitForFinished());
serverProcess.kill();
QVERIFY(serverProcess.waitForFinished());
}
#endif
}
#ifndef QT_NO_PROCESS
void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest()
{
#ifdef QT_NO_PROCESS
QSKIP("No qprocess support", SkipAll);
#else
#if defined(Q_OS_WINCE)
QSKIP("This test depends on reading data from QProcess (not supported on Qt/WinCE).");
#endif
@ -1059,8 +1061,8 @@ void tst_QUdpSocket::outOfProcessUnconnectedClientServerTest()
QVERIFY(clientProcess.waitForFinished());
serverProcess.kill();
QVERIFY(serverProcess.waitForFinished());
}
#endif
}
void tst_QUdpSocket::zeroLengthDatagram()
{