From d578b3a7c0d160d1ef89a403d1b52b1b7dbf7f79 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 5 Jul 2022 17:51:50 +0200 Subject: [PATCH] Remove manual test for QtcProcess It's not clear what this test is going to do and how to run it. Besides, it's not working at least for one year already. There is not a big loss, since it was utilizing QtcProcess::readDataFromProcess() only. Change-Id: I821cd2755d5889ddc3f772352148d595ca1816c2 Reviewed-by: Reviewed-by: hjk Reviewed-by: Christian Stenger --- tests/manual/CMakeLists.txt | 1 - tests/manual/manual.qbs | 1 - tests/manual/process/CMakeLists.txt | 11 ---- tests/manual/process/main.cpp | 90 ----------------------------- tests/manual/process/mainwindow.cpp | 63 -------------------- tests/manual/process/mainwindow.h | 45 --------------- tests/manual/process/process.pro | 25 -------- tests/manual/process/process.qbs | 14 ----- tests/manual/process/slowprocess.sh | 24 -------- 9 files changed, 274 deletions(-) delete mode 100644 tests/manual/process/CMakeLists.txt delete mode 100644 tests/manual/process/main.cpp delete mode 100644 tests/manual/process/mainwindow.cpp delete mode 100644 tests/manual/process/mainwindow.h delete mode 100644 tests/manual/process/process.pro delete mode 100644 tests/manual/process/process.qbs delete mode 100755 tests/manual/process/slowprocess.sh diff --git a/tests/manual/CMakeLists.txt b/tests/manual/CMakeLists.txt index eecadda01f7..42aaac79619 100644 --- a/tests/manual/CMakeLists.txt +++ b/tests/manual/CMakeLists.txt @@ -10,7 +10,6 @@ add_subdirectory(fakevim) # add_subdirectory(filesystemview) # add_subdirectory(genericproject) add_subdirectory(pluginview) -add_subdirectory(process) add_subdirectory(proparser) # add_subdirectory(qml) # add_subdirectory(qt4projectmanager) diff --git a/tests/manual/manual.qbs b/tests/manual/manual.qbs index f36312fcd69..566f5e8245b 100644 --- a/tests/manual/manual.qbs +++ b/tests/manual/manual.qbs @@ -11,7 +11,6 @@ Project { "deviceshell/deviceshell.qbs", "fakevim/fakevim.qbs", "pluginview/pluginview.qbs", - "process/process.qbs", "proparser/testreader.qbs", "shootout/shootout.qbs", "widgets/widgets.qbs", diff --git a/tests/manual/process/CMakeLists.txt b/tests/manual/process/CMakeLists.txt deleted file mode 100644 index 381f8b234e9..00000000000 --- a/tests/manual/process/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_qtc_test(tst_manual_qtcprocess - MANUALTEST - DEPENDS Utils - SOURCES - main.cpp - mainwindow.cpp mainwindow.h -) - -set_target_properties(tst_manual_qtcprocess PROPERTIES - OUTPUT_NAME "process" -) diff --git a/tests/manual/process/main.cpp b/tests/manual/process/main.cpp deleted file mode 100644 index 86c7ca7788d..00000000000 --- a/tests/manual/process/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** 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. -** -****************************************************************************/ - -#include "mainwindow.h" - -#include -#include - -#include -#include -#include - -#include - -static const char usage[] = -"Tests timeout behavior of Utils::QtcProcess.\n" -"Usage:\n" -" 1) Test Utils::QtcProcess (graphically)\n" -" process \n" -" 2) Test synchronous helpers of Utils::QtcProcess (tty)\n" -" process -s \n\n" -"slowprocess.sh is provided as an example script that produces slow\n" -"output. It takes an option -e to switch to stderr\n" -"No timeout should occur.\n"; - -static int testSynchronous(const QString &cmd, const QStringList &args) -{ - std::fprintf(stdout, "testSynchronous %s %s\n", qPrintable(cmd), - qPrintable(args.join(QLatin1Char(' ')))); - Utils::QtcProcess p; - p.setCommand({Utils::FilePath::fromString(cmd), args}); - p.start(); - if (!p.waitForStarted()) - return -2; - - QByteArray stdOut; - QByteArray stdErr; - if (!p.readDataFromProcess(2, &stdOut, &stdErr, false)) { - std::fputs("Timeout", stderr); - return -3; - } - std::fputs(stdOut, stdout); - std::fputs(stdErr, stderr); - return p.exitCode(); -} - -int main(int argc, char *argv[]) -{ - if (argc < 2) { - std::fputs(usage, stdout); - return -1; - } - const bool synchronous = argc > 1 && !qstrcmp(argv[1], "-s"); - int ex = 0; - if (synchronous) { - const QString cmd = QString::fromLocal8Bit(argv[2]); - QStringList args; - for (int i = 3; i < argc; i++) - args += QString::fromLocal8Bit(argv[i]); - ex = testSynchronous(cmd, args); - } else { - QApplication app(argc, argv); - MainWindow mw; - mw.show(); - ex = app.exec(); - } - return ex; -} diff --git a/tests/manual/process/mainwindow.cpp b/tests/manual/process/mainwindow.cpp deleted file mode 100644 index ceb15e8a533..00000000000 --- a/tests/manual/process/mainwindow.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** 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. -** -****************************************************************************/ - -#include "mainwindow.h" - -#include -#include - -#include -#include -#include -#include - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - m_logWindow(new QPlainTextEdit) -{ - setCentralWidget(m_logWindow); - QTimer::singleShot(200, this, &MainWindow::test); -} - -void MainWindow::append(const QString &s) -{ - m_logWindow->appendPlainText(s); -} - -void MainWindow::test() -{ - QStringList args = QApplication::arguments(); - args.pop_front(); - const QString cmd = args.front(); - args.pop_front(); - Utils::QtcProcess process; - process.setTimeoutS(2); - qDebug() << "Async: " << cmd << args; - process.setStdOutCallback([this](const QString &s) { append(s); }); - process.setStdErrCallback([this](const QString &s) { append(s); }); - process.setCommand({Utils::FilePath::fromString(cmd), args}); - process.runBlocking(); - qDebug() << process; -} diff --git a/tests/manual/process/mainwindow.h b/tests/manual/process/mainwindow.h deleted file mode 100644 index 3171b841f8b..00000000000 --- a/tests/manual/process/mainwindow.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** 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. -** -****************************************************************************/ - -#pragma once - -#include - -QT_BEGIN_NAMESPACE -class QPlainTextEdit; -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ -Q_OBJECT -public: - explicit MainWindow(QWidget *parent = 0); - - void test(); - void append(const QString &s); - -private: - QPlainTextEdit *m_logWindow; -}; diff --git a/tests/manual/process/process.pro b/tests/manual/process/process.pro deleted file mode 100644 index a8113dd2f4f..00000000000 --- a/tests/manual/process/process.pro +++ /dev/null @@ -1,25 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2010-03-01T11:08:57 -# -#------------------------------------------------- - -# Utils lib requires gui, too. -QT += core -QT += gui - -QTC_LIB_DEPENDS += utils -include(../../../qtcreator.pri) - -# -- Add creator 'utils' lib -macx:QMAKE_LFLAGS += -Wl,-rpath,\"$$IDE_BIN_PATH/..\" - -TARGET = process -CONFIG += console -CONFIG -= app_bundle -TEMPLATE = app -SOURCES += main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h diff --git a/tests/manual/process/process.qbs b/tests/manual/process/process.qbs deleted file mode 100644 index 41302a2a724..00000000000 --- a/tests/manual/process/process.qbs +++ /dev/null @@ -1,14 +0,0 @@ -import qbs - -QtcManualtest { - name: "Manual QtcProcess test" - condition: qbs.targetOS.contains("unix") - Depends { name: "Utils" } - targetName: "process" - - files: [ - "main.cpp", - "mainwindow.cpp", - "mainwindow.h" - ] -} diff --git a/tests/manual/process/slowprocess.sh b/tests/manual/process/slowprocess.sh deleted file mode 100755 index 0a9cf1687b0..00000000000 --- a/tests/manual/process/slowprocess.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -# Emulate a slow process with continous output - -I=0 -STDERR=0 -if [ " $1" = " -e" ] -then - echo stderr - STDERR=1 - shift 1 -fi - -while [ $I -lt 20 ] -do - if [ $STDERR -ne 0 ] - then - echo $I 1>&2 - else - echo $I - fi - I=`expr $I + 1` - sleep 1 -done