Fix QStandardPath test on some linuxes
On one suse box I have both /usr/bin/sh and /bin/sh which means that the test should prefer the one first in the path instead of random order. Change-Id: Ie94bf8404479fa42a36a8ee45e09986114693871 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
35f8bcd438
commit
04acfea2d2
|
|
@ -308,13 +308,16 @@ void tst_qstandardpaths::testDataLocation()
|
|||
|
||||
#ifndef Q_OS_WIN
|
||||
// Find "sh" on Unix.
|
||||
// It may exist twice, in /bin/sh and /usr/bin/sh, in that case use the PATH order.
|
||||
static inline QFileInfo findSh()
|
||||
{
|
||||
const char *shPaths[] = {"/bin/sh", "/usr/bin/sh", 0};
|
||||
for (const char **shPath = shPaths; *shPath; ++shPath) {
|
||||
const QFileInfo fi = QFileInfo(QLatin1String(*shPath));
|
||||
if (fi.exists())
|
||||
return fi;
|
||||
QLatin1String sh("/sh");
|
||||
QByteArray pEnv = qgetenv("PATH");
|
||||
const QLatin1Char pathSep(':');
|
||||
const QStringList rawPaths = QString::fromLocal8Bit(pEnv.constData()).split(pathSep, QString::SkipEmptyParts);
|
||||
foreach (const QString &path, rawPaths) {
|
||||
if (QFile::exists(path + sh))
|
||||
return path + sh;
|
||||
}
|
||||
return QFileInfo();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue