Fixed tst_QFile when redirecting stdin/stdout/stderr to/from files.
authorRohan McGovern <rohan.mcgovern@nokia.com>
Wed, 15 Feb 2012 07:56:30 +0000 (17:56 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 16 Feb 2012 00:57:27 +0000 (01:57 +0100)
openStandardStreamsBufferedStreams would fail if standard streams were
redirected to a file (e.g. ./tst_qfile > testlog.txt).

openStandardStreamsFileDescriptors already has a workaround, so apply it
here too.

Change-Id: Iffe9d7864909e489e77c1114e80c4e3bc70a8722
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
tests/auto/corelib/io/qfile/tst_qfile.cpp

index 0ed1b8e..d1a0deb 100644 (file)
@@ -3028,25 +3028,28 @@ void tst_QFile::openStandardStreamsBufferedStreams()
     {
         QFile in;
         in.open(stdin, QIODevice::ReadOnly);
+        if (!in.isSequential())
+            QSKIP("Standard input redirected.");
         QCOMPARE( in.pos(), (qint64)0 );
         QCOMPARE( in.size(), (qint64)0 );
-        QVERIFY( in.isSequential() );
     }
 
     {
         QFile out;
         out.open(stdout, QIODevice::WriteOnly);
+        if (!out.isSequential())
+            QSKIP("Standard output redirected.");
         QCOMPARE( out.pos(), (qint64)0 );
         QCOMPARE( out.size(), (qint64)0 );
-        QVERIFY( out.isSequential() );
     }
 
     {
         QFile err;
         err.open(stderr, QIODevice::WriteOnly);
+        if (!err.isSequential())
+            QSKIP("Standard error redirected.");
         QCOMPARE( err.pos(), (qint64)0 );
         QCOMPARE( err.size(), (qint64)0 );
-        QVERIFY( err.isSequential() );
     }
 }