diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-01 12:34:10 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-01 22:37:31 +0100 |
commit | f0942bd8cb3b1f5e1de2c920c2ad894763277dd8 (patch) | |
tree | ae0efd84196a5c613ff49d7b134fe6f8fe9257d6 /tests | |
parent | 9e09b8dc4842823407909f404d5213d4643a8d37 (diff) |
Windows: Fix qabstractfilenengine-test.
The test fails if the repository is checked out with
Windows line endings. Try to work around.
Basically, ensure that common developers can conveniently
run the test.
Change-Id: I91f31b830ba7ba305deea782737d4e07a89420eb
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp index a81633341d..9f8fcda01c 100644 --- a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp @@ -598,11 +598,25 @@ void tst_QAbstractFileEngine::fileIO() { // Reading QFile file(fileName); - QVERIFY(!file.isOpen()); - QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)); + /* For an exact match, this test requires the repository to + * be checked out with UNIX-style line endings on Windows. + * Try to succeed also for the common case of checking out with autocrlf + * by reading the file as text and checking if the size matches + * the original size + the '\r' characters added by autocrlf. */ + + QFile::OpenMode openMode = QIODevice::ReadOnly | QIODevice::Unbuffered; +#ifdef Q_OS_WIN + openMode |= QIODevice::Text; +#endif + QVERIFY(file.open(openMode)); QVERIFY(file.isOpen()); +#ifdef Q_OS_WIN + const qint64 convertedSize = fileSize + readContent.count('\n'); + if (file.size() == convertedSize) + fileSize = convertedSize; +#endif QCOMPARE(file.size(), fileSize); QCOMPARE(file.pos(), qint64(0)); |