From b6505dcee680ec6894c3e08e954e970dc4a3b965 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 12 Jun 2012 13:01:49 +0200 Subject: Fix QLibrary test. - Use correct working directory. Task-number: QTQAINFRA-428 Change-Id: I31fdc941fe21e2efa29d742a5b8cd89f2214e81c Reviewed-by: Rohan McGovern --- tests/auto/qlibrary/tst/tst.pro | 3 +-- tests/auto/qlibrary/tst_qlibrary.cpp | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/auto/qlibrary/tst/tst.pro b/tests/auto/qlibrary/tst/tst.pro index 1ce70cb..e66e859 100644 --- a/tests/auto/qlibrary/tst/tst.pro +++ b/tests/auto/qlibrary/tst/tst.pro @@ -2,6 +2,7 @@ load(qttest_p4) SOURCES += ../tst_qlibrary.cpp TARGET = ../tst_qlibrary QT = core +CONFIG -= app_bundle win32 { CONFIG(debug, debug|release) { @@ -30,5 +31,3 @@ wince*: { } else { DEFINES += SRCDIR=\\\"$$PWD/../\\\" } - -win32:CONFIG+=insignificant_test # QTQAINFRA-428 diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp index 3742744..fe2bcd0 100644 --- a/tests/auto/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/qlibrary/tst_qlibrary.cpp @@ -165,6 +165,15 @@ tst_QLibrary::tst_QLibrary() int argc = 1; app = new QCoreApplication(argc,&argv); #endif +#ifdef Q_OS_WIN + // cd up from debug/release paths + QString directory = QDir::currentPath(); + if (directory.endsWith(QLatin1String("debug"), Qt::CaseInsensitive) + || directory.endsWith(QLatin1String("release"), Qt::CaseInsensitive)) { + directory.truncate(directory.lastIndexOf(QLatin1Char('/'))); + QDir::setCurrent(directory); + } +#endif } tst_QLibrary::~tst_QLibrary() @@ -241,6 +250,13 @@ void tst_QLibrary::load_data() # endif // Q_OS_UNIX } +static inline QByteArray msgCannotLoad(const QString &lib, const QString &why) +{ + const QString result = QString::fromLatin1("Cannot load %1 (in %2): %3") + .arg(lib, QDir::currentPath(), why); + return result.toLatin1(); +} + void tst_QLibrary::load() { QFETCH( QString, lib ); @@ -249,8 +265,8 @@ void tst_QLibrary::load() QLibrary library( lib ); bool ok = library.load(); if ( result ) { - QVERIFY( ok ); - QVERIFY(library.unload()); + QVERIFY2(ok, msgCannotLoad(lib, library.errorString())); + QVERIFY(library.unload()); } else { QVERIFY( !ok ); } -- cgit v0.12