Commit Graph

144 Commits

Author SHA1 Message Date
Jarek Kobus
2794b5e543 tst_QtcProcess: Get rid of lineCallbackIntern() test
This test introduced some additional private API to QtcProcess.
This makes refactorings of QtcProcess harder, as we need to
handle this artificial code working.

We have a real lineCallback() test instead which doesn't
employ this private API.

Change-Id: Idbc314210cecc2044e1ccc298e5d3e0a9747e811
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-04-11 15:26:10 +00:00
Jarek Kobus
936c44f367 Introduce ProcessResultData
It should be useful when reimplementing ProcessInterface.
It replaces 4 virtual methods with just 1.

Task-number: QTCREATORBUG-27358
Change-Id: I2dafbfbc25f8f016ff2aa19c1a176335a4a7498c
Reviewed-by: hjk <hjk@qt.io>
2022-04-11 06:51:51 +00:00
Jarek Kobus
5b923954c0 QtcProcess: Make exitMessage() a const method
Change-Id: Ibb0aaf0bf3bf216673646ea7b869fd7e55e6b81c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-04-05 13:36:48 +00:00
Jarek Kobus
ab11c4373b QtcProcess: Introduce done() signal
Introduce QtcProcess::done() signal. It's similar to
QtcProcess::finished() signal, but also emitted when
process failed to start (so after QProcess::FailedToStart
error occurred).

SshRemoteProcess::finished() signal was already behaving
like this. So, we remove special handling of
FailedToStart error in this class and connect all clients
of SshRemoteProcess to done() signal, instead of finished().

Task-number: QTCREATORBUG-27232
Change-Id: If4240e2172f3f706e812bca669a1d5b24bdc3285
Reviewed-by: hjk <hjk@qt.io>
2022-04-04 13:28:12 +00:00
Jarek Kobus
365a05640b QtcProcess: Get rid of setErrorString() method
It's internal method, not meant to be used outside.
It's only used in case of FailedToStart error.
Remove it also from ProcessInterface.
Leave it inside DefaultImpl and its subclasses only.

Remove m_errorString field from ProcessSetupData.

Change-Id: Ie605b95c2ff605ab1259045f1a5b16049207c1d3
Reviewed-by: hjk <hjk@qt.io>
2022-04-04 10:20:34 +00:00
Jarek Kobus
b76b8b1542 ProcessReaper: Implement custom terminate for CtrlCStub case
Move CtrlCStub-specific interrupt into ProcessHelper.

Amends 7d7e4af3afb5ba9d0ed5210018dd6be67abda469

Change-Id: I5cd9a750c4a89587a874515f752b0144df4b8309
Reviewed-by: hjk <hjk@qt.io>
2022-03-31 12:48:42 +00:00
hjk
27c8f00d73 Utils: Un-seat QtcProcess from ProcessInterface
I find it too confusing to have that inheritance only to enforce
similar interfaces.

Change-Id: I9da68ea59c04f709228e0874460e987115b30f56
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-03-31 10:14:36 +00:00
Jarek Kobus
d7ff76be69 QtcProcess: Drop return value from stopProcess()
It wasn't used at all.

Change-Id: Ife0989c73c67b6106e61c40931f318ee7a5b062d
Reviewed-by: hjk <hjk@qt.io>
2022-03-24 08:12:03 +00:00
Jarek Kobus
6d853023c6 QtcProcess: Fix a comment
Amends 8e0ae8ba96

Change-Id: Ie5b99525ec7de0565cd79ed52c7fc094d5509ddc
Reviewed-by: hjk <hjk@qt.io>
2022-03-23 16:00:46 +00:00
Jarek Kobus
82108e949a ProcessInterface: Rename interruptProcess() -> interrupt()
Both functionalities meant to do the same.

Change-Id: Idd9373cdb24b7b41f9e4befb09326c339263eeb1
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-03-10 08:41:05 +00:00
Jarek Kobus
8e0ae8ba96 QtcProcess: Limit the inclusion of qtcprocess.h
Move the rest of QtcProcess enums to processenums.h.
Move ExitCodeInterpreter into processenums.h.
Remove superfluous Utils:: prefix.

Change-Id: Iaa596f353d33d6930085a621b114cc15a35caa80
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-02 13:30:39 +00:00
Jarek Kobus
7b234e0fae QtcProcess: Introduce virtual emit* temporarily
Introduce emitStarted, emitFinished and emitErrorOccurred
virtual protected methods for QtcProcess subclasses.
It makes it easier to connect to self signals and
filter out the unneeded emissions. This is a temporary
change until QtcProcess is de-virtualized.

Amends ff68923846

Change-Id: I784676458e86314e092366e3b3b1244dfe2712f3
Reviewed-by: hjk <hjk@qt.io>
2022-02-28 14:52:15 +00:00
Jarek Kobus
fd7bf831ba Introduce processImplHook
Call new hook from inside QtcProcess::start().
This hook calls new virtual method
IDevice::createProcessInterface().
That's all what should be needed from device
to setup properly device specific process.

Make QtcProcess::createProcessInterface() private now.

Change-Id: I2136698063bafc846ebc2d3db6cc11376902eff0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-02-22 17:28:31 +00:00
Jarek Kobus
6360cffc80 Fix passing environment to remote
After removing Runnable parameter from DeviceProcess::start()
(see 95c9579c58) we are now
setting the runnable's environment to the remote process
directly. This is now used in 2 places:

1. For forming the proper fullCommandLine(), so that
the passed environment is expanded to command line
arguments

2. For running the remote process itself.

Before the mentioned change these two environments were
separated (1st was taken from run environment aspect,
2nd was left with its default value - see SshProcess c'tor).
After the mentioned change 1 and 2 are equal (i.e. both are
env aspect). This affects running app in terminal,
as the aspect env is applied to the stub process, so it
can't start properly.

This change brings the separation back.

Amends 95c9579c58

Change-Id: I5efe82e19d3fb5608f97e56c2f4b7651643e156a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-21 14:21:33 +00:00
Jarek Kobus
192bbb7618 ProcessInterface: Place the class in separate header file
Change-Id: I9f3924f7cf69af58f93fc19f0af25c6fa9cfb55e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-02-21 14:18:40 +00:00
Jarek Kobus
357c39f2d7 Base QtcProcess on ProcessInterface
Change-Id: I51bc6b7aea8e2d3aa0ef9fbba3b5fc796058c8cb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-02-18 23:35:55 +00:00
Jarek Kobus
0e6aed8127 QtcProcess: Make processId() virtual
I guess this was an intention in the below commit.

Amends 9ec997b376

Change-Id: Ie55d18f764dc73601f6d911a22323fd2a39c4eb9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-02-18 10:58:24 +00:00
Jarek Kobus
48960b5cfc QtcProcess: Extract QtcProcess specific enums into separate header
Change-Id: Ib3498f189000fd8f5501130c0d280b0f5ae83849
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-02-18 10:51:55 +00:00
Jarek Kobus
a056aa8f95 QtcProcess: Make API inventory
Group the common methods of ProcessInterface in the
QtcProcess API together. Order them the same.
This is a preparation step for basing
QtcProcess on ProcessInterface.

Group separately the other accessors and mutators that
base on ProcessSetupData m_setup field. This group
may became a part of ProcessInterface later.

Group the utils enhancemets (or decoration API) separately,
as that really doesn't influence the kernel of QtcProcess.

Add some TODO comments, to be considered later.

Change-Id: I0bf78284e71f4610eb0cf3508bc178f84fac679a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-18 09:38:44 +00:00
Jarek Kobus
e49f57b3ec ProcessInterface: Hide m_setup in protected section
Change-Id: I8931ae0eabbc1962a8cf104fbbb849149e0cf88b
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-18 09:34:22 +00:00
Jarek Kobus
fdc8193f13 ProcessInterface: Drop ProcessMode from c'tor
Drop it also from registerHandle() methods, as it wasn't
used there.

Change-Id: I34b72c38368b82f22d73314fe3cd429ed43cadbc
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-18 08:29:24 +00:00
Jarek Kobus
ae36fd943a ProcessInterface: Drop arguments from finished() signal
Make the API more similar to QtcProcess API.

Change-Id: If62051908b7974008bebda21dd288b02e7a772f3
Reviewed-by: hjk <hjk@qt.io>
2022-02-17 16:58:19 +00:00
Jarek Kobus
82c2450fbe Reuse ProcessSetupData in CallerHandle
Change-Id: I4a2d3fef15331343e7763149550280b722fc3781
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:30:01 +00:00
Jarek Kobus
aa3166df78 ProcessInterface: Simplify start() API
Get rid of program and arguments parameters from
start() method. Get rid of customStart() and isCustomStart()
methods. Provide a default implementation for start() method.
Introduce virtual doDefaultStart() method, to be called when
default implementation for start() is used() - it's being
triggered by a call to defaultStart(). When some implemetation
provides the custom implemetation of start() method
(e.g. TerminalImpl), the doDefaultStart() may stay unimplemented
(won't be called).

Rename WrongFileNameFailure to WrongCommandFailure, as that's
being used also in case when command arguments parsing failed.

Cleanup some unimplemented or unused fields of ProcessLauncherImpl.

Change-Id: I87661e9838dc30888034b2fa62d47c861bf8f9dd
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:20:08 +00:00
Jarek Kobus
d06449d1a5 ProcessInterface: Remove setEnvironment()
Use environment from ProcessSetupData instead.

Change-Id: I8f0436b8ce024ca5ce39ae2cd842b4d195f2c54d
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:14:30 +00:00
Jarek Kobus
d520d457c1 ProcessInterface: Simplify customStart() method
Change-Id: I8940ca016076e42a73774a18a24b6b5ce2cb81ad
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:09:31 +00:00
Jarek Kobus
5c3a08bc4b ProcessInterface: Simplify start() method
Don't pass writeData, as that's available through
ProcessSetupData.

Change-Id: Ic55b21c6a3338168ee251bcc1c57594f50c52d2f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 09:09:24 +00:00
Jarek Kobus
c49ce24a92 ProcessInterface: Make a copy of ProcessSetupData
Don't share the same instance of data with the QtcProcess
itself, as some of the fields needs to be modified just
for the starting purposes. In this way we avoid cyclic
modifications of the original data on subsequent runs.

Change-Id: I937978ee92f848d247025939ac5b0c6c60c29ff7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-16 08:22:23 +00:00
Jarek Kobus
ccb42b3c74 ProcessInterface: Remove setWorkingDirectory()
It's a part of passed ProcessSetupData.

Change-Id: I125d31cb1b316c1802d1d9d7fb5e1c5b3a3b8c18
Reviewed-by: hjk <hjk@qt.io>
2022-02-15 14:55:46 +00:00
Jarek Kobus
5c1dc2fd5e Move more internal data into ProcessSetupData
It's going to be reused in other parts of implementation.

Change-Id: I4721bba28537d3f00c20c0f3c8e5ca633dc8727e
Reviewed-by: hjk <hjk@qt.io>
2022-02-15 14:54:42 +00:00
Jarek Kobus
ce40605934 ProcessInterface: Remove program() method
It looks it's really unneeded.

Change-Id: Ie9447abfbe57968e5f5302be6b23cb950c4d0ea7
Reviewed-by: hjk <hjk@qt.io>
2022-02-14 16:24:56 +00:00
Jarek Kobus
6f1285f508 ProcessInterface: Use Environment and FilePath
Use Utils::Environment for of environment.
Use Utils::FilePath for workingDirectory.

Change-Id: I6b717139f8ff7ddbd629fb22cf816b2303fb5e6a
Reviewed-by: hjk <hjk@qt.io>
2022-02-14 15:16:30 +00:00
hjk
95c9579c58 ProjectExplorer: Normalize DeviceProcess::start() signature
Change-Id: I2915be34d4a1eed64567874dcf0263b7583cc142
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-02-14 15:10:12 +00:00
Jarek Kobus
fd36b4a501 Make ProcessInterface public
It's going to be subclassed in LinuxDevice.

Change-Id: I6308d7cf75a7e16cd02de585612000a1b983fadc
Reviewed-by: hjk <hjk@qt.io>
2022-02-14 10:57:27 +00:00
hjk
e2cb64471a Utils: Move QtcProcess constructor setup data to shared setup data
This includes replacing DeviceProcess terminal handling with base
member.

Change-Id: Id1541bfce33c71dddc71b4816ad0b174dce3879c
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-02-11 17:33:48 +00:00
Jarek Kobus
f5b946abbe LinuxDevice: Implement runProcess()
Change-Id: I5300d36119ffb9fdd82a2ba7e02f76edc0fe2eda
Reviewed-by: hjk <hjk@qt.io>
2022-02-03 14:20:18 +00:00
Jarek Kobus
239688180d Fix running as root
There is no need for TerminalRunner::setRunAsRoot()
as debugger is already being run as root.
Implement runAsRoot for non-terminal QtcProcess, too.

Fixes: QTCREATORBUG-26964
Change-Id: Id5110db86b7b809a5608714464241cee73875f2b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-02-03 10:23:25 +00:00
hjk
9ec997b376 ProjectExplorer: Base DeviceProcess on QtcProcess
... instead of having a member.

Change-Id: I75e8d7600eb17c7528fe9525d2e1aa871b282ad9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-01-31 07:44:24 +00:00
hjk
3769169b8e Utils: Introduce a struct for QtcProcess ctor arguments
We'll need a lot of combinations.

Change-Id: Ic92ad6fba1d96c42571be76f7c24b253f210b132
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-28 12:20:35 +00:00
Jarek Kobus
1d15a934cd QtcProcess: Get rid of useTerminal
Remove SshRemoteProcessRunner::runInTerminal() method,
it wasn't used anywhere (just in test).
Remove QtcProcess::useTerminal, as process should be
created in TerminalOn mode when there is a need for terminal.
Add a parameter to
SshRemoteProcess::fullLocalCommandLine(bool inTerminal)
as this may still be needed when running application
through ssh from terminal (ssh -tt option).

Change-Id: I71911082fcca190b82a1106a2ca1ca48dc5d4c79
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit 95a9b22f6f)
2022-01-28 12:19:12 +00:00
Jarek Kobus
c216e883b2 QtcProcess: Forward declare QTextCodec
No need to include it in the QtcProcess header.

Change-Id: Ie1acfeaad332bbd2205f3457ad313d9fabed69b7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-01-25 17:20:53 +00:00
Jarek Kobus
a09630d50e TerminalRunner: Use QtcProcess in terminal mode instead of ConsoleProcess
Change-Id: I5ddc521ed62947a6bd09eb048408fc9573069615
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-01-25 14:56:28 +00:00
Jarek Kobus
5127d155d2 QtcProcess: Get rid of setProcessUserEventWhileRunning()
Introduce EventLoopMode enum and pass it to the
QtcProcess::runBlocking() instead. There is no need to
store this setting. By default this value is NoEventLoop.

Change-Id: Icad98b77bec5280b79039b7e5aa4ec408261521c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-01-25 08:44:11 +00:00
Jarek Kobus
8260074c67 Integrate ConsoleProcess into QtcProcess
Change-Id: I8e2b43ef27af6ff279b575a8d43f1ff918562951
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-01-25 08:36:09 +00:00
Jarek Kobus
d6f56254d1 Get rid of QtcProcess::workingDirectory() overload
Adapt all callers' code so that it passes the FilePath
instead of QString. As a consequence introduce
TemporaryDirectory::masterDirectoryFilePath() and use
it where easily possible.

Change-Id: I14564949b3b916921e32a2957c84c03d1da43af2
Reviewed-by: hjk <hjk@qt.io>
2022-01-18 17:18:34 +00:00
hjk
104ea4accc Make some qHash and comparison operators overloads hidden friends
Restricts lookup scope more to necessary bits.

Change-Id: Ia42c95aaa70534843b7f6a90bfc56d2a1202c612
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-12-06 17:10:49 +00:00
hjk
8cb5c3cfdd Ssh: Use base QtcProcess' useTerminal for SshRemoteProcess
Still trying to ramp down non-QtcProcess interfaces.

Change-Id: I6b4ae6788f5021959ff3eb35bbade2157a6d67fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-12-06 15:30:00 +00:00
hjk
e64ce914f9 Utils/Ssh: Move SshRemoteProces::isRunning() to QtcProcess base
... and use it on a few places.

Change-Id: Id2cea709e355a46821a720e593740ac032888ced
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-12-06 13:44:23 +00:00
hjk
4aea533fe5 Utils: Remove compatibility typedef SynchronousProcess
Change-Id: Iad80129668142bd518fc8c88bf03a7b3afd8be47
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Alp Öz <aoz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-14 03:29:08 +00:00
Alessandro Portale
2fc0ce4843 Utils: Introduce QtcProcess::toStandaloneCommandLine()
The goal is to make a QtcProcess incl. environment, working directory,
executable and arguments testable, e.g. in a terminal. The new
toStandaloneCommandLine() returns a string containing the command line
for a call of "env" the data of the QtcProcess instance as parameters.

To be used like:
  qDebug().noquote() << qtcProc.toStandaloneCommandLine();

..and the debug output can be pasted into a terminal.

Change-Id: Ib6cbea290e1eff3279d6e0a67076a624312af879
Reviewed-by: hjk <hjk@qt.io>
2021-09-10 11:49:07 +00:00