RemoteLinux: Honor working directory setting again

Fixes: QTCREATORBUG-28900
Change-Id: I163877a749f378b2aa7579c1985e58f8a9d87e2c
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2023-04-20 17:59:26 +02:00
parent c6a98002fd
commit ce7b99bc88
3 changed files with 26 additions and 5 deletions

View File

@@ -12,6 +12,7 @@
#include <utils/filestreamer.h> #include <utils/filestreamer.h>
#include <utils/filestreamermanager.h> #include <utils/filestreamermanager.h>
#include <utils/processinterface.h> #include <utils/processinterface.h>
#include <utils/qtcprocess.h>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
@@ -181,6 +182,21 @@ void FileSystemAccessTest::testCreateRemoteFile()
QVERIFY(!testFilePath.exists()); QVERIFY(!testFilePath.exists());
} }
void FileSystemAccessTest::testWorkingDirectory()
{
const FilePath dir = baseFilePath() / "testdir with space and 'various' \"quotes\" here";
QVERIFY(dir.ensureWritableDir());
QtcProcess proc;
proc.setCommand({"pwd", {}});
proc.setWorkingDirectory(dir);
proc.start();
QVERIFY(proc.waitForFinished());
const QString out = proc.readAllStandardOutput().trimmed();
QCOMPARE(out, dir.path());
const QString err = proc.readAllStandardOutput();
QVERIFY(err.isEmpty());
}
void FileSystemAccessTest::testDirStatus() void FileSystemAccessTest::testDirStatus()
{ {
FilePath filePath = baseFilePath(); FilePath filePath = baseFilePath();

View File

@@ -24,6 +24,7 @@ private slots:
void testCreateRemoteFile_data(); void testCreateRemoteFile_data();
void testCreateRemoteFile(); void testCreateRemoteFile();
void testWorkingDirectory();
void testDirStatus(); void testDirStatus();
void testBytesAvailable(); void testBytesAvailable();
void testFileActions(); void testFileActions();

View File

@@ -612,13 +612,17 @@ void SshProcessInterfacePrivate::start()
cmd.addArg("-tt"); cmd.addArg("-tt");
const CommandLine full = q->m_setup.m_commandLine; const CommandLine full = q->m_setup.m_commandLine;
if (!full.isEmpty()) { if (!full.isEmpty()) { // Empty is ok in case of opening a terminal.
CommandLine inner;
const QString wd = q->m_setup.m_workingDirectory.path();
if (!wd.isEmpty())
inner.addCommandLineWithAnd({"cd", {wd}});
if (!useTerminal) { if (!useTerminal) {
// Empty is ok in case of opening a terminal. const QString pidArg = QString("%1\\$\\$%1").arg(QString::fromLatin1(s_pidMarker));
cmd.addArgs(QString("echo ") + s_pidMarker + "\\$\\$" + s_pidMarker + " \\&\\& ", inner.addCommandLineWithAnd({"echo", pidArg, CommandLine::Raw});
CommandLine::Raw);
} }
cmd.addCommandLineAsArgs(full, CommandLine::Raw); inner.addCommandLineWithAnd(full);
cmd.addCommandLineAsSingleArg(inner);
} }
m_process.setProcessImpl(q->m_setup.m_processImpl); m_process.setProcessImpl(q->m_setup.m_processImpl);