From f0942bd8cb3b1f5e1de2c920c2ad894763277dd8 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 1 Dec 2011 12:34:10 +0100 Subject: 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 --- .../io/qabstractfileengine/tst_qabstractfileengine.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tests/auto/corelib') 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)); -- cgit v1.2.3