forked from qt-creator/qt-creator
Fix getting source file name on OSX
If the current executable is an app bundle the source file location is given as relative path from the app bundles location instead of the "real" executable somewhere inside the app bundle. Change-Id: I37ad2daae5a7ebde65c0e76a8a9a7837401bc749 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
#include "testxmloutputreader.h"
|
||||
#include "testresult.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QProcess>
|
||||
#include <QFileInfo>
|
||||
@@ -47,6 +49,17 @@ static QString decode(const QString& original)
|
||||
return result;
|
||||
}
|
||||
|
||||
static QString constructSourceFilePath(const QString &path, const QString &filePath,
|
||||
const QString &app)
|
||||
{
|
||||
if (Utils::HostOsInfo::isMacHost() && !app.isEmpty()) {
|
||||
const QString fileName(QFileInfo(app).fileName());
|
||||
return QFileInfo(path.left(path.lastIndexOf(fileName + QLatin1String(".app"))), filePath)
|
||||
.canonicalFilePath();
|
||||
}
|
||||
return QFileInfo(path, filePath).canonicalFilePath();
|
||||
}
|
||||
|
||||
static bool xmlStartsWith(const QString &code, const QString &start, QString &result)
|
||||
{
|
||||
if (code.startsWith(start)) {
|
||||
@@ -229,7 +242,8 @@ void TestXmlOutputReader::processOutput()
|
||||
if (line.endsWith(QLatin1String("/>"))) {
|
||||
TestResult testResult(className, testCase, dataTag, result, description);
|
||||
if (!file.isEmpty())
|
||||
file = QFileInfo(m_testApplication->workingDirectory(), file).canonicalFilePath();
|
||||
file = constructSourceFilePath(m_testApplication->workingDirectory(), file,
|
||||
m_testApplication->program());
|
||||
testResult.setFileName(file);
|
||||
testResult.setLine(lineNumber);
|
||||
testResultCreated(testResult);
|
||||
@@ -244,7 +258,8 @@ void TestXmlOutputReader::processOutput()
|
||||
if (line == QLatin1String("</Message>") || line == QLatin1String("</Incident>")) {
|
||||
TestResult testResult(className, testCase, dataTag, result, description);
|
||||
if (!file.isEmpty())
|
||||
file = QFileInfo(m_testApplication->workingDirectory(), file).canonicalFilePath();
|
||||
file = constructSourceFilePath(m_testApplication->workingDirectory(), file,
|
||||
m_testApplication->program());
|
||||
testResult.setFileName(file);
|
||||
testResult.setLine(lineNumber);
|
||||
testResultCreated(testResult);
|
||||
|
Reference in New Issue
Block a user