Add QT_NO_PROCESS guards in tests where they are missing
A handful of tests lack QT_NO_PROCESS guards, making them non-compilable on Qt builds with no QProcess support. This commit does not change QProcess-specific tests, which should be left out of the build using the .pro file mechanism. Change-Id: Iac8562428abc1f59ccbb23bf5c3a919785e41f12 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
5bd6a4b71a
commit
cd582f8410
@ -101,6 +101,7 @@ void tst_qmessagehandler::initTestCase()
|
||||
QVERIFY2(!m_appDir.isEmpty(), qPrintable(
|
||||
QString::fromLatin1("Couldn't find helper app dir starting from %1.").arg(QDir::currentPath())));
|
||||
|
||||
#ifndef QT_NO_PROCESS
|
||||
m_baseEnvironment = QProcess::systemEnvironment();
|
||||
for (int i = 0; i < m_baseEnvironment.count(); ++i) {
|
||||
if (m_baseEnvironment.at(i).startsWith("QT_MESSAGE_PATTERN=")) {
|
||||
@ -108,6 +109,7 @@ void tst_qmessagehandler::initTestCase()
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
void tst_qmessagehandler::cleanup()
|
||||
@ -641,6 +643,9 @@ void tst_qmessagehandler::cleanupFuncinfo()
|
||||
|
||||
void tst_qmessagehandler::qMessagePattern()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
QProcess process;
|
||||
const QString appExe = m_appDir + "/app";
|
||||
|
||||
@ -710,10 +715,14 @@ void tst_qmessagehandler::qMessagePattern()
|
||||
output.replace("\r\n", "\n");
|
||||
#endif
|
||||
QCOMPARE(QString::fromLatin1(output), QString::fromLatin1(expected));
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
void tst_qmessagehandler::qMessagePatternIf()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
QProcess process;
|
||||
const QString appExe = m_appDir + "/app";
|
||||
|
||||
@ -773,6 +782,7 @@ void tst_qmessagehandler::qMessagePatternIf()
|
||||
QVERIFY(output.contains("QT_MESSAGE_PATTERN: %{if-*} cannot be nested"));
|
||||
QVERIFY(output.contains("A DEBUG qDebug"));
|
||||
QVERIFY(output.contains("A qWarning"));
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qmessagehandler)
|
||||
|
@ -77,7 +77,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
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
void tst_QLockFile::lockUnlock()
|
||||
@ -111,6 +111,9 @@ void tst_QLockFile::lockUnlock()
|
||||
|
||||
void tst_QLockFile::lockOutOtherProcess()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
// Lock
|
||||
const QString fileName = dir.path() + "/lockOtherProcess";
|
||||
QLockFile lockFile(fileName);
|
||||
@ -132,6 +135,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
|
||||
}
|
||||
|
||||
static QLockFile::LockError tryLockFromThread(const QString &fileName)
|
||||
@ -228,6 +232,9 @@ void tst_QLockFile::staleLockFromCrashedProcess_data()
|
||||
|
||||
void tst_QLockFile::staleLockFromCrashedProcess()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
QFETCH(int, staleLockTime);
|
||||
const QString fileName = dir.path() + "/staleLockFromCrashedProcess";
|
||||
|
||||
@ -245,10 +252,14 @@ void tst_QLockFile::staleLockFromCrashedProcess()
|
||||
QVERIFY(secondLock.tryLock());
|
||||
#endif
|
||||
QCOMPARE(int(secondLock.error()), int(QLockFile::NoError));
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
void tst_QLockFile::staleShortLockFromBusyProcess()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
const QString fileName = dir.path() + "/staleLockFromBusyProcess";
|
||||
|
||||
QProcess proc;
|
||||
@ -274,10 +285,14 @@ void tst_QLockFile::staleShortLockFromBusyProcess()
|
||||
|
||||
proc.waitForFinished();
|
||||
QVERIFY(secondLock.tryLock());
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
void tst_QLockFile::staleLongLockFromBusyProcess()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
const QString fileName = dir.path() + "/staleLockFromBusyProcess";
|
||||
|
||||
QProcess proc;
|
||||
@ -297,6 +312,7 @@ void tst_QLockFile::staleLongLockFromBusyProcess()
|
||||
QVERIFY(!secondLock.removeStaleLockFile());
|
||||
|
||||
proc.waitForFinished();
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
static QString tryStaleLockFromThread(const QString &fileName)
|
||||
@ -326,6 +342,9 @@ static QString tryStaleLockFromThread(const QString &fileName)
|
||||
|
||||
void tst_QLockFile::staleLockRace()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
// Multiple threads notice a stale lock at the same time
|
||||
// Only one thread should delete it, otherwise a race will ensue
|
||||
const QString fileName = dir.path() + "/sharedFile";
|
||||
@ -341,6 +360,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
|
||||
}
|
||||
|
||||
void tst_QLockFile::noPermissions()
|
||||
|
@ -766,6 +766,7 @@ void tst_QMimeDatabase::fromThreads()
|
||||
// sync dtor blocks waiting for finished
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PROCESS
|
||||
static bool runUpdateMimeDatabase(const QString &path) // TODO make it a QMimeDatabase method?
|
||||
{
|
||||
const QString umdCommand = QString::fromLatin1("update-mime-database");
|
||||
@ -799,6 +800,7 @@ static bool waitAndRunUpdateMimeDatabase(const QString &path)
|
||||
}
|
||||
return runUpdateMimeDatabase(path);
|
||||
}
|
||||
#endif // !QT_NO_PROCESS
|
||||
|
||||
static void checkHasMimeType(const QString &mimeType)
|
||||
{
|
||||
@ -821,6 +823,9 @@ QT_END_NAMESPACE
|
||||
|
||||
void tst_QMimeDatabase::installNewGlobalMimeType()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
qmime_secondsBetweenChecks = 0;
|
||||
|
||||
QMimeDatabase db;
|
||||
@ -862,10 +867,14 @@ void tst_QMimeDatabase::installNewGlobalMimeType()
|
||||
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
|
||||
QString::fromLatin1("application/octet-stream"));
|
||||
QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
void tst_QMimeDatabase::installNewLocalMimeType()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
qmime_secondsBetweenChecks = 0;
|
||||
|
||||
QMimeDatabase db;
|
||||
@ -913,6 +922,7 @@ void tst_QMimeDatabase::installNewLocalMimeType()
|
||||
QCOMPARE(db.mimeTypeForFile(QLatin1String("foo.ymu"), QMimeDatabase::MatchExtension).name(),
|
||||
QString::fromLatin1("application/octet-stream"));
|
||||
QVERIFY(!db.mimeTypeForName(QLatin1String("text/x-suse-ymp")).isValid());
|
||||
#endif
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(tst_QMimeDatabase)
|
||||
|
@ -430,6 +430,9 @@ void tst_QCommandLineParser::testSingleDashWordOptionModes()
|
||||
|
||||
void tst_QCommandLineParser::testVersionOption()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
#ifdef Q_OS_WINCE
|
||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
||||
#endif
|
||||
@ -443,6 +446,7 @@ void tst_QCommandLineParser::testVersionOption()
|
||||
output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
|
||||
#endif
|
||||
QCOMPARE(output, QString("qcommandlineparser_test_helper 1.0\n"));
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
void tst_QCommandLineParser::testHelpOption_data()
|
||||
@ -478,6 +482,9 @@ void tst_QCommandLineParser::testHelpOption_data()
|
||||
|
||||
void tst_QCommandLineParser::testHelpOption()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
#ifdef Q_OS_WINCE
|
||||
QSKIP("Reading and writing to a process is not supported on Qt/CE");
|
||||
#endif
|
||||
@ -524,6 +531,7 @@ void tst_QCommandLineParser::testHelpOption()
|
||||
expectedResizeHelp.replace("testhelper/", "testhelper\\");
|
||||
#endif
|
||||
QCOMPARE(output, QString(expectedResizeHelp));
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QCommandLineParser)
|
||||
|
@ -79,6 +79,7 @@ static QString makespec()
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace QTest {
|
||||
#ifndef QT_NO_PROCESS
|
||||
class QExternalProcess: public QProcess
|
||||
{
|
||||
protected:
|
||||
@ -99,6 +100,7 @@ namespace QTest {
|
||||
}
|
||||
#endif
|
||||
};
|
||||
#endif // !QT_NO_PROCESS
|
||||
|
||||
class QExternalTestPrivate
|
||||
{
|
||||
@ -565,6 +567,7 @@ namespace QTest {
|
||||
|
||||
bool QExternalTestPrivate::runQmake()
|
||||
{
|
||||
#ifndef QT_NO_PROCESS
|
||||
if (temporaryDirPath.isEmpty())
|
||||
qWarning() << "Temporary directory is expected to be non-empty";
|
||||
|
||||
@ -607,10 +610,16 @@ namespace QTest {
|
||||
}
|
||||
|
||||
return ok && exitCode == 0;
|
||||
#else // QT_NO_PROCESS
|
||||
return false;
|
||||
#endif // QT_NO_PROCESS
|
||||
}
|
||||
|
||||
bool QExternalTestPrivate::runMake(Target target)
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
return false;
|
||||
#else
|
||||
if (temporaryDirPath.isEmpty())
|
||||
qWarning() << "Temporary directory is expected to be non-empty";
|
||||
|
||||
@ -666,6 +675,7 @@ namespace QTest {
|
||||
std_err += make.readAllStandardError();
|
||||
|
||||
return ok;
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
bool QExternalTestPrivate::commonSetup(const QByteArray &body)
|
||||
|
@ -196,6 +196,7 @@ void tst_QClipboard::testSignals()
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX)
|
||||
static bool runHelper(const QString &program, const QStringList &arguments, QByteArray *errorMessage)
|
||||
{
|
||||
#ifndef QT_NO_PROCESS
|
||||
QProcess process;
|
||||
process.setReadChannelMode(QProcess::ForwardedChannels);
|
||||
process.start(program, arguments);
|
||||
@ -231,6 +232,12 @@ static bool runHelper(const QString &program, const QStringList &arguments, QByt
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else // QT_NO_PROCESS
|
||||
Q_UNUSED(program)
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorMessage)
|
||||
return false;
|
||||
#endif // QT_NO_PROCESS
|
||||
}
|
||||
|
||||
// Test that pasted text remains on the clipboard after a Qt application exits.
|
||||
|
@ -2227,6 +2227,9 @@ void tst_QTcpSocket::suddenRemoteDisconnect_data()
|
||||
|
||||
void tst_QTcpSocket::suddenRemoteDisconnect()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
QFETCH(QString, client);
|
||||
QFETCH(QString, server);
|
||||
|
||||
@ -2280,6 +2283,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect()
|
||||
#endif
|
||||
QCOMPARE(clientProcess.readAll().constData(), "SUCCESS\n");
|
||||
QCOMPARE(serverProcess.readAll().constData(), "SUCCESS\n");
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -489,6 +489,8 @@ void tst_Selftests::runSubTest_data()
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PROCESS
|
||||
|
||||
static void insertEnvironmentVariable(QString const& name, QProcessEnvironment &result)
|
||||
{
|
||||
const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment();
|
||||
@ -688,13 +690,19 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !QT_NO_PROCESS
|
||||
|
||||
void tst_Selftests::runSubTest()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
QFETCH(QString, subdir);
|
||||
QFETCH(QStringList, loggers);
|
||||
QFETCH(QStringList, arguments);
|
||||
|
||||
doRunSubTest(subdir, loggers, arguments);
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
// attribute must contain ="
|
||||
|
@ -139,6 +139,9 @@ void addClientProperty(const QString& key, const QString& value)
|
||||
*/
|
||||
void fetchCustomClientProperties()
|
||||
{
|
||||
#ifdef QT_NO_PROCESS
|
||||
QSKIP("This test requires QProcess support");
|
||||
#else
|
||||
QString script = "hostinfo.sh"; //### TBD: Windows implementation (hostinfo.bat)
|
||||
|
||||
QProcess runScript;
|
||||
@ -161,6 +164,7 @@ void fetchCustomClientProperties()
|
||||
else
|
||||
qDebug() << "Unparseable script output ignored:" << line;
|
||||
}
|
||||
#endif // !QT_NO_PROCESS
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user