From 7bb7345dad86efd18ada010342b614917fbb5767 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 21 Oct 2014 14:31:19 +0200 Subject: tests: tst_qdeclarativelanguage: fix filesystem case sensitivity importIncorrectCase() and errors(incorrectCase) give different error messages depending on the case sensitivity of the file system on OS X. Those are in turn different than error messages on other operating systems with case-sensitive filesystems. This patch is very similar to the one that was done in qtdeclarative: 2ebf4ba4710a01a038d05cfea741e5538bb4567f for QTBUG-37622 Change-Id: Ib13d717712cf88b476ca7edd8aababd7f5456c50 Task-number: QTBUG-41961 Reviewed-by: Liang Qi --- .../data/incorrectCase.errors.sensitive.osx.txt | 2 ++ .../tst_qdeclarativelanguage.cpp | 30 ++++++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.osx.txt diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.osx.txt b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.osx.txt new file mode 100644 index 00000000..b5e6f770 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.osx.txt @@ -0,0 +1,2 @@ +3:1:Type IncorrectCaseType unavailable +-1:-1:File not found diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 0539f33f..4f834e7a 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -50,6 +50,16 @@ DEFINE_BOOL_CONFIG_OPTION(qmlCheckTypes, QML_CHECK_TYPES) +static inline bool isCaseSensitiveFileSystem(const QString &path) { + Q_UNUSED(path) +#if defined(Q_OS_OSX) + return pathconf(path.toLatin1().constData(), _PC_CASE_SENSITIVE); +#elif defined(Q_OS_WIN) + return false; +#else + return true; +#endif +} /* This test case covers QML language issues. This covers everything that does not @@ -404,13 +414,15 @@ void tst_qdeclarativelanguage::errors_data() #endif QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false; QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false; - QTest::newRow("incorrectCase") << "incorrectCase.qml" -#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) - << "incorrectCase.errors.insensitive.txt" + + const QString expectedError = isCaseSensitiveFileSystem(dataDirectory()) ? +#if defined(Q_OS_OSX) + QStringLiteral("incorrectCase.errors.sensitive.osx.txt") : #else - << "incorrectCase.errors.sensitive.txt" + QStringLiteral("incorrectCase.errors.sensitive.txt") : #endif - << false; + QStringLiteral("incorrectCase.errors.insensitive.txt"); + QTest::newRow("incorrectCase") << "incorrectCase.qml" << expectedError << false; QTest::newRow("metaobjectRevision.1") << "metaobjectRevision.1.qml" << "metaobjectRevision.1.errors.txt" << false; QTest::newRow("metaobjectRevision.2") << "metaobjectRevision.2.qml" << "metaobjectRevision.2.errors.txt" << false; @@ -1837,11 +1849,9 @@ void tst_qdeclarativelanguage::importIncorrectCase() QList errors = component.errors(); QCOMPARE(errors.count(), 1); -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) - QString expectedError = QLatin1String("File name case mismatch"); -#else - QString expectedError = QLatin1String("File not found"); -#endif + const QString expectedError = isCaseSensitiveFileSystem(dataDirectory()) ? + QStringLiteral("File not found") : + QStringLiteral("File name case mismatch"); QCOMPARE(errors.at(0).description(), expectedError); } -- cgit v1.2.3