diff options
Diffstat (limited to 'tests/auto/corelib/tools/qsharedpointer/externaltests.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qsharedpointer/externaltests.cpp | 69 |
1 files changed, 23 insertions, 46 deletions
diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp index d1bb89f549..c676924668 100644 --- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "externaltests.h" @@ -80,32 +55,34 @@ namespace QTest { { if (process.state() == QProcess::Running) { process.terminate(); - QThread::msleep(20); + QThread::sleep(std::chrono::milliseconds{20}); if (process.state() == QProcess::Running) process.kill(); } } +# ifdef Q_OS_UNIX class QExternalProcess: public QProcess { - protected: -#ifdef Q_OS_UNIX - void setupChildProcess() + public: + QExternalProcess() { - // run in user code - QProcess::setupChildProcess(); - - if (processChannelMode() == ForwardedChannels) { - // reopen /dev/tty into stdin - int fd = ::open("/dev/tty", O_RDONLY); - if (fd == -1) - return; - ::dup2(fd, 0); - ::close(fd); - } + setChildProcessModifier([this]() { + // run in user code + if (processChannelMode() == ForwardedChannels) { + // reopen /dev/tty into stdin + int fd = ::open("/dev/tty", O_RDONLY); + if (fd == -1) + return; + ::dup2(fd, 0); + ::close(fd); + } + }); } -#endif }; +# else + using QExternalProcess = QProcess; +# endif #endif // QT_CONFIG(process) class QExternalTestPrivate @@ -341,7 +318,7 @@ namespace QTest { if (qtModules & QExternalTest::QtScript) sourceCode += "#include <QtScript/QtScript>\n"; if (qtModules & QExternalTest::QtTest) - sourceCode += "#include <QtTest/QtTest>\n"; + sourceCode += "#include <QTest>\n"; if (qtModules & QExternalTest::QtDBus) sourceCode += "#include <QtDBus/QtDBus>\n"; if (qtModules & QExternalTest::QtWebKit) @@ -360,7 +337,7 @@ namespace QTest { "}\n" "\n" "#ifdef Q_OS_WIN\n" - "#include <windows.h>\n" + "#include <qt_windows.h>\n" "#if defined(Q_CC_MSVC)\n" "#include <crtdbg.h>\n" "#endif\n" @@ -588,7 +565,7 @@ namespace QTest { << QLatin1String("project.pro"); qmake.setWorkingDirectory(temporaryDirPath); - QString cmd = QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmake"; + QString cmd = QLibraryInfo::path(QLibraryInfo::BinariesPath) + "/qmake"; #ifdef Q_OS_WIN cmd.append(".exe"); #endif |