From 5fa777de961efad954004b879fbaa6cd606c0966 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Wed, 1 Feb 2012 10:08:33 +1000 Subject: [PATCH] Fixed qfile unittest on windows - Changed to set working directory based on subprogram stdinprocess's directory location. - Changed QProcess execution of subprograms to use relative paths. Change-Id: Idbccca635f0f61adba9721bcceeceb0a8a961dcf Reviewed-by: Jason McDonald Reviewed-by: Rohan McGovern --- tests/auto/corelib/io/qfile/test/test.pro | 9 +-------- tests/auto/corelib/io/qfile/tst_qfile.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro index 2f1e500..2611ff3 100644 --- a/tests/auto/corelib/io/qfile/test/test.pro +++ b/tests/auto/corelib/io/qfile/test/test.pro @@ -9,13 +9,6 @@ TESTDATA += ../dosfile.txt ../noendofline.txt ../testfile.txt \ ../Makefile ../forCopying.txt ../forRenaming.txt \ ../resources/file1.ext1 -win32 { - CONFIG(debug, debug|release) { - TARGET = ../../debug/tst_qfile - } else { - TARGET = ../../release/tst_qfile - } - LIBS+=-lole32 -luuid -} +win32: LIBS+=-lole32 -luuid mac*:CONFIG+=insignificant_test diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 20193ab..00e4535 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -343,9 +343,9 @@ void tst_QFile::cleanup() void tst_QFile::initTestCase() { - // chdir to testdata directory and use relative paths. - QString testdata_dir = QFileInfo(QFINDTESTDATA("testfile.txt")).absolutePath(); - QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); + QString workingDir = QFileInfo(QFINDTESTDATA("stdinprocess")).absolutePath(); + QVERIFY2(!workingDir.isEmpty(), qPrintable("Could not find working directory!")); + QVERIFY2(QDir::setCurrent(workingDir), qPrintable("Could not chdir to " + workingDir)); QFile::remove("noreadfile"); @@ -832,7 +832,7 @@ void tst_QFile::readAllStdin() QByteArray lotsOfData(1024, '@'); // 10 megs QProcess process; - process.start(QFINDTESTDATA("stdinprocess/stdinprocess")+" all"); + process.start("stdinprocess/stdinprocess all"); QVERIFY( process.waitForStarted() ); for (int i = 0; i < 5; ++i) { QTest::qWait(1000); @@ -867,7 +867,7 @@ void tst_QFile::readLineStdin() for (int i = 0; i < 2; ++i) { QProcess process; - process.start((QFINDTESTDATA("stdinprocess/stdinprocess")+QString(" line %1").arg(i)), QIODevice::Text | QIODevice::ReadWrite); + process.start((QString("stdinprocess/stdinprocess line %1").arg(i)), QIODevice::Text | QIODevice::ReadWrite); for (int i = 0; i < 5; ++i) { QTest::qWait(1000); process.write(lotsOfData); @@ -901,7 +901,7 @@ void tst_QFile::readLineStdin_lineByLine() #else for (int i = 0; i < 2; ++i) { QProcess process; - process.start(QFINDTESTDATA("stdinprocess/stdinprocess")+ QString(" line %1").arg(i), QIODevice::Text | QIODevice::ReadWrite); + process.start(QString("stdinprocess/stdinprocess line %1").arg(i), QIODevice::Text | QIODevice::ReadWrite); QVERIFY(process.waitForStarted()); for (int j = 0; j < 3; ++j) { -- 2.7.4