Commit f173dc82 authored by Christian Stenger's avatar Christian Stenger
Browse files

AutoTest: Provide more details on failure or guess



If a test case cannot be started or does crash while executing
these information might help to sort out configuration problems.

Change-Id: I406d5e69475d05931d4c4c4738f8528c6d74c585
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 750f25d9
......@@ -130,6 +130,7 @@ void TestConfiguration::completeTestInformation(int runMode)
m_executableFile = exeString;
m_project = project;
m_guessedConfiguration = true;
m_guessedFrom = rc->displayName();
if (runMode == TestRunner::Debug)
m_runConfig = new TestRunConfiguration(rc->target(), this);
}
......@@ -203,11 +204,6 @@ void TestConfiguration::setProject(Project *project)
m_project = project;
}
void TestConfiguration::setGuessedConfiguration(bool guessed)
{
m_guessedConfiguration = guessed;
}
QString TestConfiguration::executableFilePath() const
{
if (m_executableFile.isEmpty())
......
......@@ -66,7 +66,6 @@ public:
void setDisplayName(const QString &displayName);
void setEnvironment(const Utils::Environment &env);
void setProject(ProjectExplorer::Project *project);
void setGuessedConfiguration(bool guessed);
QStringList testCases() const { return m_testCases; }
int testCaseCount() const { return m_testCaseCount; }
......@@ -77,7 +76,9 @@ public:
Utils::Environment environment() const { return m_environment; }
ProjectExplorer::Project *project() const { return m_project.data(); }
TestRunConfiguration *runConfiguration() const { return m_runConfig; }
bool guessedConfiguration() const { return m_guessedConfiguration; }
bool isGuessed() const { return m_guessedConfiguration; }
QString runConfigDisplayName() const { return m_guessedConfiguration ? m_guessedFrom
: m_displayName; }
virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
QProcess *app) const = 0;
......@@ -91,6 +92,7 @@ private:
QString m_workingDir;
QString m_buildDir;
QString m_displayName;
QString m_guessedFrom;
Utils::Environment m_environment;
QPointer<ProjectExplorer::Project> m_project;
bool m_guessedConfiguration = false;
......
......@@ -42,6 +42,7 @@
#include <projectexplorer/target.h>
#include <utils/runextensions.h>
#include <utils/hostosinfo.h>
#include <QFuture>
#include <QFutureInterface>
......@@ -95,6 +96,28 @@ void TestRunner::setSelectedTests(const QList<TestConfiguration *> &selected)
m_selectedTests = selected;
}
static QString processInformation(const QProcess &proc)
{
QString information("\nCommand line: " + proc.program() + ' ' + proc.arguments().join(' '));
QStringList important = { "PATH" };
if (Utils::HostOsInfo::isLinuxHost())
important.append("LD_LIBRARY_PATH");
else if (Utils::HostOsInfo::isMacHost())
important.append({ "DYLD_LIBRARY_PATH", "DYLD_FRAMEWORK_PATH" });
const QProcessEnvironment &environment = proc.processEnvironment();
for (const QString &var : important)
information.append('\n' + var + ": " + environment.value(var));
return information;
}
static QString rcInfo(const TestConfiguration * const config)
{
QString info = '\n' + TestRunner::tr("Run configuration:") + ' ';
if (config->isGuessed())
info += TestRunner::tr("guessed from");
return info + " \"" + config->runConfigDisplayName() + '"';
}
static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
const QList<TestConfiguration *> selectedTests,
const TestSettings &settings)
......@@ -107,11 +130,14 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
config->completeTestInformation(TestRunner::Run);
if (config->project()) {
testCaseCount += config->testCaseCount();
if (!omitRunConfigWarnings && config->guessedConfiguration()) {
futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageWarn,
TestRunner::tr("Project's run configuration was guessed for \"%1\".\n"
"This might cause trouble during execution."
).arg(config->displayName()))));
if (!omitRunConfigWarnings && config->isGuessed()) {
QString message = TestRunner::tr(
"Project's run configuration was guessed for \"%1\".\n"
"This might cause trouble during execution.\n"
"(guessed from \"%2\")");
message = message.arg(config->displayName()).arg(config->runConfigDisplayName());
futureInterface.reportResult(
TestResultPtr(new FaultyTestResult(Result::MessageWarn, message)));
}
} else {
futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageWarn,
......@@ -172,11 +198,15 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
}
} else {
futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
TestRunner::tr("Failed to start test for project \"%1\".").arg(testConfiguration->displayName()))));
TestRunner::tr("Failed to start test for project \"%1\".")
.arg(testConfiguration->displayName()) + processInformation(testProcess)
+ rcInfo(testConfiguration))));
}
if (testProcess.exitStatus() == QProcess::CrashExit) {
futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
TestRunner::tr("Test for project \"%1\" crashed.").arg(testConfiguration->displayName()))));
TestRunner::tr("Test for project \"%1\" crashed.")
.arg(testConfiguration->displayName()) + processInformation(testProcess)
+ rcInfo(testConfiguration))));
}
if (canceledByTimeout) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment