forked from qt-creator/qt-creator
Squish: Fix script generation
Handle whitespaces inside the application's name and arguments correctly. Change-Id: I5f3fc7c83e7b1e694e9f2a4583c6ac06b7528ff6 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -12,23 +12,25 @@
|
||||
namespace Squish {
|
||||
namespace Internal {
|
||||
|
||||
static QByteArray startApplication(Language language, const QString &application,
|
||||
const QStringList &args)
|
||||
static QByteArray startApplication(Language language,
|
||||
const QString &application,
|
||||
const QString &args)
|
||||
{
|
||||
const QString app = application.contains(' ') ? QString("\\\"" + application + "\\\"")
|
||||
: application;
|
||||
QStringList parameters;
|
||||
parameters << app;
|
||||
if (args.isEmpty())
|
||||
parameters << QString(args).replace('"', "\\\"");
|
||||
|
||||
switch (language) {
|
||||
case Language::Python:
|
||||
case Language::Perl:
|
||||
case Language::JavaScript:
|
||||
case Language::Ruby:
|
||||
if (args.isEmpty())
|
||||
return QByteArray("startApplication(\"" + application.toUtf8() + "\")");
|
||||
return QByteArray("startApplication(\"" + application.toUtf8() + ' '
|
||||
+ args.join(' ').toUtf8() + "\")");
|
||||
return QByteArray("startApplication(\"" + parameters.join(' ').toUtf8() + "\")");
|
||||
case Language::Tcl:
|
||||
if (args.isEmpty())
|
||||
return QByteArray("startApplication \"" + application.toUtf8() + "\"");
|
||||
return QByteArray("startApplication \"" + application.toUtf8() + ' '
|
||||
+ args.join(' ').toUtf8() + "\"");
|
||||
return QByteArray("startApplication \"" + parameters.join(' ').toUtf8() + "\"");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -115,7 +117,7 @@ ScriptHelper::ScriptHelper(Language language)
|
||||
bool ScriptHelper::writeScriptFile(const Utils::FilePath &outScriptFile,
|
||||
const Utils::FilePath &snippetFile,
|
||||
const QString &application,
|
||||
const QStringList &arguments) const
|
||||
const QString &arguments) const
|
||||
{
|
||||
if (!snippetFile.isReadableFile())
|
||||
return false;
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
bool writeScriptFile(const Utils::FilePath &outScriptFile,
|
||||
const Utils::FilePath &snippetFile,
|
||||
const QString &application,
|
||||
const QStringList &arguments) const;
|
||||
const QString &arguments) const;
|
||||
private:
|
||||
Language m_language;
|
||||
};
|
||||
|
||||
@@ -739,7 +739,7 @@ void SquishTools::onRecorderFinished()
|
||||
"test" + m_suiteConf.scriptExtension());
|
||||
bool result = helper.writeScriptFile(testFile, m_currentRecorderSnippetFile,
|
||||
m_suiteConf.aut(),
|
||||
m_suiteConf.arguments().split(' ', Qt::SkipEmptyParts));
|
||||
m_suiteConf.arguments());
|
||||
qCInfo(LOG) << "Wrote recorded test case" << testFile.toUserOutput() << " " << result;
|
||||
m_currentRecorderSnippetFile.removeFile();
|
||||
m_currentRecorderSnippetFile.clear();
|
||||
|
||||
Reference in New Issue
Block a user