forked from qt-creator/qt-creator
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: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -10,7 +10,6 @@ add_subdirectory(fakevim)
|
|||||||
# add_subdirectory(filesystemview)
|
# add_subdirectory(filesystemview)
|
||||||
# add_subdirectory(genericproject)
|
# add_subdirectory(genericproject)
|
||||||
add_subdirectory(pluginview)
|
add_subdirectory(pluginview)
|
||||||
add_subdirectory(process)
|
|
||||||
add_subdirectory(proparser)
|
add_subdirectory(proparser)
|
||||||
# add_subdirectory(qml)
|
# add_subdirectory(qml)
|
||||||
# add_subdirectory(qt4projectmanager)
|
# add_subdirectory(qt4projectmanager)
|
||||||
|
@@ -11,7 +11,6 @@ Project {
|
|||||||
"deviceshell/deviceshell.qbs",
|
"deviceshell/deviceshell.qbs",
|
||||||
"fakevim/fakevim.qbs",
|
"fakevim/fakevim.qbs",
|
||||||
"pluginview/pluginview.qbs",
|
"pluginview/pluginview.qbs",
|
||||||
"process/process.qbs",
|
|
||||||
"proparser/testreader.qbs",
|
"proparser/testreader.qbs",
|
||||||
"shootout/shootout.qbs",
|
"shootout/shootout.qbs",
|
||||||
"widgets/widgets.qbs",
|
"widgets/widgets.qbs",
|
||||||
|
@@ -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"
|
|
||||||
)
|
|
@@ -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 <utils/filepath.h>
|
|
||||||
#include <utils/qtcprocess.h>
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
static const char usage[] =
|
|
||||||
"Tests timeout behavior of Utils::QtcProcess.\n"
|
|
||||||
"Usage:\n"
|
|
||||||
" 1) Test Utils::QtcProcess (graphically)\n"
|
|
||||||
" process <cmd> <args>\n"
|
|
||||||
" 2) Test synchronous helpers of Utils::QtcProcess (tty)\n"
|
|
||||||
" process -s <cmd> <args>\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;
|
|
||||||
}
|
|
@@ -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 <utils/fileutils.h>
|
|
||||||
#include <utils/qtcprocess.h>
|
|
||||||
|
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
@@ -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 <QMainWindow>
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
@@ -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
|
|
@@ -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"
|
|
||||||
]
|
|
||||||
}
|
|
@@ -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
|
|
Reference in New Issue
Block a user