aboutsummaryrefslogtreecommitdiffstats
path: root/tests/benchmarker
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2017-01-02 16:28:24 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2017-01-02 16:38:40 +0000
commit549a796fdc5d959be294b28b81d721a48fe4ae5d (patch)
treea11f97288d411d03ec5705d53bf5b89803024ace /tests/benchmarker
parent16a08516371356b5105413243f6fa0a5d7ea1ef1 (diff)
Fix restoration of symbolic commits
qbs-benchmarker tries to restore the original commit of the qbs repository. To determine that commit the command git describe HEAD is used. For the 1.7 branch this produces something like v1.7.0-26-g2bc9373 which then is passed to 'git checkout'. Afterwards the repo is in detached HEAD state. Use 'git symbolic-ref' to determine the correct original branch name. Fall back to the old method if that doesn't work. Change-Id: I21526db1efceebcf5102eed9da43478871880ab1 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests/benchmarker')
-rw-r--r--tests/benchmarker/benchmarker.cpp13
-rw-r--r--tests/benchmarker/runsupport.cpp5
-rw-r--r--tests/benchmarker/runsupport.h2
3 files changed, 17 insertions, 3 deletions
diff --git a/tests/benchmarker/benchmarker.cpp b/tests/benchmarker/benchmarker.cpp
index 69faa780c..becf60dec 100644
--- a/tests/benchmarker/benchmarker.cpp
+++ b/tests/benchmarker/benchmarker.cpp
@@ -96,7 +96,18 @@ void Benchmarker::benchmark()
void Benchmarker::rememberCurrentRepoState()
{
QByteArray commit;
- runProcess(QStringList() << "git" << "describe" << "HEAD", m_qbsRepo, &commit);
+ int exitCode = 0;
+ try {
+ runProcess(QStringList() << "git" << "symbolic-ref" << "--short" << "HEAD", m_qbsRepo,
+ &commit, &exitCode);
+ } catch (const Exception &) {
+ if (exitCode == 0) {
+ // runProcess did not throw because of the exit code.
+ throw;
+ }
+ // Fallback, in case git cannot retrieve a nice symbolic name.
+ runProcess(QStringList() << "git" << "describe" << "HEAD", m_qbsRepo, &commit);
+ }
m_commitToRestore = QString::fromLatin1(commit);
}
diff --git a/tests/benchmarker/runsupport.cpp b/tests/benchmarker/runsupport.cpp
index 360cc871b..669cd3ae5 100644
--- a/tests/benchmarker/runsupport.cpp
+++ b/tests/benchmarker/runsupport.cpp
@@ -36,7 +36,8 @@
namespace qbsBenchmarker {
-void runProcess(const QStringList &commandLine, const QString &workingDir, QByteArray *output)
+void runProcess(const QStringList &commandLine, const QString &workingDir, QByteArray *output,
+ int *exitCode)
{
QStringList args = commandLine;
const QString command = args.takeFirst();
@@ -51,6 +52,8 @@ void runProcess(const QStringList &commandLine, const QString &workingDir, QByte
throw Exception(QString::fromLatin1("Error running '%1': %2")
.arg(command, p.errorString()));
}
+ if (exitCode)
+ *exitCode = p.exitCode();
if (p.exitCode() != 0) {
QString errorString = QString::fromLatin1("Command '%1' finished with exit code %2.")
.arg(command).arg(p.exitCode());
diff --git a/tests/benchmarker/runsupport.h b/tests/benchmarker/runsupport.h
index 4bfd4289b..9c09019c8 100644
--- a/tests/benchmarker/runsupport.h
+++ b/tests/benchmarker/runsupport.h
@@ -39,7 +39,7 @@ QT_END_NAMESPACE
namespace qbsBenchmarker {
void runProcess(const QStringList &commandLine, const QString& workingDir = QString(),
- QByteArray *output = 0);
+ QByteArray *output = nullptr, int *exitCode = nullptr);
} // namespace qbsBenchmarker