summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-03-13 23:12:08 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-15 05:40:04 +0000
commit6694772702a386a6f228c47545e8d5caf19b6649 (patch)
tree2edce29c1c27c0281bac9206b92236ac288c687f
parent46fefd3d30af65dd3b5f1a7988aa6da61f98e253 (diff)
Baseline: Allow setting git commit through environment variable
Widget tests run in VMs that don't have their own git clone. Change-Id: I20ab32affabfc7ce6dfaa445306b19efb51803e9 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 16d154ca5f10e8d44c0959181de5bf80697c7bdb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/baseline/shared/baselineprotocol.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/tests/baseline/shared/baselineprotocol.cpp b/tests/baseline/shared/baselineprotocol.cpp
index ab6ced204a..d3177b3d8b 100644
--- a/tests/baseline/shared/baselineprotocol.cpp
+++ b/tests/baseline/shared/baselineprotocol.cpp
@@ -70,24 +70,26 @@ PlatformInfo PlatformInfo::localHostInfo()
#endif
pi.insert(PI_OSVersion, QSysInfo::kernelVersion());
+ QString gc = qEnvironmentVariable("BASELINE_GIT_COMMIT");
#if QT_CONFIG(process)
- QProcess git;
- QString cmd;
- QStringList args;
-#if defined(Q_OS_WIN)
- cmd = QLS("cmd.exe");
- args << QLS("/c") << QLS("git");
-#else
- cmd = QLS("git");
-#endif
- args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s");
- git.start(cmd, args);
- git.waitForFinished(3000);
- if (!git.exitCode())
- pi.insert(PI_GitCommit, QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified());
- else
- pi.insert(PI_GitCommit, QLS("Unknown"));
+ if (gc.isEmpty()) {
+ QProcess git;
+ QString cmd;
+ QStringList args;
+ #if defined(Q_OS_WIN)
+ cmd = QLS("cmd.exe");
+ args << QLS("/c") << QLS("git");
+ #else
+ cmd = QLS("git");
+ #endif
+ args << QLS("log") << QLS("--max-count=1") << QLS("--pretty=%H [%an] [%ad] %s");
+ git.start(cmd, args);
+ git.waitForFinished(3000);
+ if (!git.exitCode())
+ gc = QString::fromLocal8Bit(git.readAllStandardOutput().constData()).simplified();
+ }
#endif // QT_CONFIG(process)
+ pi.insert(PI_GitCommit, gc.isEmpty() ? QLS("Unknown") : gc);
if (qEnvironmentVariableIsSet("JENKINS_HOME"))
pi.setAdHocRun(false);