From 2509a5b5a49ea52948b434578ff29e7f9ba60b40 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 8 Dec 2011 16:11:13 +0100 Subject: QFile-test: Do not fail when run with redirected stdout/stderr. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check whether stdout/stderr is sequential. Change-Id: Ia6311e265f0da03dce5b05d78a2058e0c2098bbf Reviewed-by: João Abecasis --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tests/auto/corelib/io/qfile') diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 90cd1aedb9..0f9293f872 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2971,29 +2971,35 @@ void tst_QFile::openStandardStreamsFileDescriptors() //it does not have functions to simply open them like below . QSKIP("Opening standard streams on Windows CE via descriptor not implemented"); #endif - // Using file descriptors + /* in/out/err.isSequential() are only true when run in a console (CI); + * it is false when they are redirected from/to files. + * Prevent failures in case someone runs tests with stdout/stderr redirected. */ + { QFile in; in.open(STDIN_FILENO, 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_FILENO, QIODevice::WriteOnly); + QVERIFY(out.open(STDOUT_FILENO, 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_FILENO, QIODevice::WriteOnly); + if (!err.isSequential()) + QSKIP("Standard error redirected."); QCOMPARE( err.pos(), (qint64)0 ); QCOMPARE( err.size(), (qint64)0 ); - QVERIFY( err.isSequential() ); } } -- cgit v1.2.3