From 95d0b27711c2f75af233c9a083c9818400db0957 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 3 Feb 2012 10:22:13 +1000 Subject: testlib: Add selftests for skip and fail inside cleanupTestCase(). Change-Id: I9bbe774c3259338d452cd1eb1a6f37a85db15921 Reviewed-by: Rohan McGovern --- .../selftests/expected_failcleanup.lightxml | 15 ++++++ .../testlib/selftests/expected_failcleanup.txt | 8 +++ .../testlib/selftests/expected_failcleanup.xml | 18 +++++++ .../selftests/expected_failcleanup.xunitxml | 13 +++++ .../selftests/expected_skipcleanup.lightxml | 15 ++++++ .../testlib/selftests/expected_skipcleanup.txt | 8 +++ .../testlib/selftests/expected_skipcleanup.xml | 18 +++++++ .../selftests/expected_skipcleanup.xunitxml | 15 ++++++ .../testlib/selftests/failcleanup/failcleanup.pro | 7 +++ .../selftests/failcleanup/tst_failcleanup.cpp | 63 ++++++++++++++++++++++ tests/auto/testlib/selftests/selftests.pri | 2 +- tests/auto/testlib/selftests/selftests.qrc | 8 +++ .../testlib/selftests/skipcleanup/skipcleanup.pro | 7 +++ .../selftests/skipcleanup/tst_skipcleanup.cpp | 63 ++++++++++++++++++++++ tests/auto/testlib/selftests/tst_selftests.cpp | 2 + 15 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 tests/auto/testlib/selftests/expected_failcleanup.lightxml create mode 100644 tests/auto/testlib/selftests/expected_failcleanup.txt create mode 100644 tests/auto/testlib/selftests/expected_failcleanup.xml create mode 100644 tests/auto/testlib/selftests/expected_failcleanup.xunitxml create mode 100644 tests/auto/testlib/selftests/expected_skipcleanup.lightxml create mode 100644 tests/auto/testlib/selftests/expected_skipcleanup.txt create mode 100644 tests/auto/testlib/selftests/expected_skipcleanup.xml create mode 100644 tests/auto/testlib/selftests/expected_skipcleanup.xunitxml create mode 100644 tests/auto/testlib/selftests/failcleanup/failcleanup.pro create mode 100644 tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp create mode 100644 tests/auto/testlib/selftests/skipcleanup/skipcleanup.pro create mode 100644 tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp diff --git a/tests/auto/testlib/selftests/expected_failcleanup.lightxml b/tests/auto/testlib/selftests/expected_failcleanup.lightxml new file mode 100644 index 0000000000..83ce7a7b15 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_failcleanup.lightxml @@ -0,0 +1,15 @@ + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_failcleanup.txt b/tests/auto/testlib/selftests/expected_failcleanup.txt new file mode 100644 index 0000000000..08c10b1823 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_failcleanup.txt @@ -0,0 +1,8 @@ +********* Start testing of tst_FailCleanup ********* +Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +PASS : tst_FailCleanup::initTestCase() +PASS : tst_FailCleanup::aTestFunction() +FAIL! : tst_FailCleanup::cleanupTestCase() 'false' returned FALSE. (Fail inside cleanupTestCase) + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp(59)] +Totals: 2 passed, 1 failed, 0 skipped +********* Finished testing of tst_FailCleanup ********* diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xml b/tests/auto/testlib/selftests/expected_failcleanup.xml new file mode 100644 index 0000000000..5d0d2c5751 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_failcleanup.xml @@ -0,0 +1,18 @@ + + + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xunitxml b/tests/auto/testlib/selftests/expected_failcleanup.xunitxml new file mode 100644 index 0000000000..6e35566be8 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_failcleanup.xunitxml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.lightxml b/tests/auto/testlib/selftests/expected_skipcleanup.lightxml new file mode 100644 index 0000000000..d2bc3b766e --- /dev/null +++ b/tests/auto/testlib/selftests/expected_skipcleanup.lightxml @@ -0,0 +1,15 @@ + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.txt b/tests/auto/testlib/selftests/expected_skipcleanup.txt new file mode 100644 index 0000000000..c97f31c2a9 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_skipcleanup.txt @@ -0,0 +1,8 @@ +********* Start testing of tst_SkipCleanup ********* +Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +PASS : tst_SkipCleanup::initTestCase() +PASS : tst_SkipCleanup::aTestFunction() +SKIP : tst_SkipCleanup::cleanupTestCase() Skip inside cleanupTestCase. + Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp(59)] +Totals: 2 passed, 0 failed, 1 skipped +********* Finished testing of tst_SkipCleanup ********* diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xml b/tests/auto/testlib/selftests/expected_skipcleanup.xml new file mode 100644 index 0000000000..8fbfc7711c --- /dev/null +++ b/tests/auto/testlib/selftests/expected_skipcleanup.xml @@ -0,0 +1,18 @@ + + + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml b/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml new file mode 100644 index 0000000000..b8f67e2d07 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/tests/auto/testlib/selftests/failcleanup/failcleanup.pro b/tests/auto/testlib/selftests/failcleanup/failcleanup.pro new file mode 100644 index 0000000000..426d7cc45b --- /dev/null +++ b/tests/auto/testlib/selftests/failcleanup/failcleanup.pro @@ -0,0 +1,7 @@ +SOURCES += tst_failcleanup.cpp +QT = core testlib + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = failcleanup diff --git a/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp b/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp new file mode 100644 index 0000000000..a1b3b2d15a --- /dev/null +++ b/tests/auto/testlib/selftests/failcleanup/tst_failcleanup.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class tst_FailCleanup: public QObject +{ +Q_OBJECT +private slots: + void aTestFunction() const; + void cleanupTestCase() const; +}; + +void tst_FailCleanup::aTestFunction() const +{ + QVERIFY(true); +} + +void tst_FailCleanup::cleanupTestCase() const +{ + QVERIFY2(false, "Fail inside cleanupTestCase"); +} + +QTEST_APPLESS_MAIN(tst_FailCleanup) +#include "tst_failcleanup.moc" diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 95664c3793..9d4b2bd600 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -4,4 +4,4 @@ SUBPROGRAMS = subtest warnings maxwarnings cmptest globaldata skip \ exceptionthrow qexecstringlist datatable commandlinedata\ benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \ benchliboptions xunit badxml longstring float printdatatags \ - printdatatagswithglobaltags findtestdata counting + printdatatagswithglobaltags findtestdata counting skipcleanup failcleanup diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index d10aa56ceb..f882068f6d 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -64,6 +64,10 @@ expected_expectfail.txt expected_expectfail.xml expected_expectfail.xunitxml + expected_failcleanup.lightxml + expected_failcleanup.txt + expected_failcleanup.xml + expected_failcleanup.xunitxml expected_failinit.lightxml expected_failinit.txt expected_failinit.xml @@ -108,6 +112,10 @@ expected_skip.txt expected_skip.xml expected_skip.xunitxml + expected_skipcleanup.lightxml + expected_skipcleanup.txt + expected_skipcleanup.xml + expected_skipcleanup.xunitxml expected_skipinit.lightxml expected_skipinit.txt expected_skipinit.xml diff --git a/tests/auto/testlib/selftests/skipcleanup/skipcleanup.pro b/tests/auto/testlib/selftests/skipcleanup/skipcleanup.pro new file mode 100644 index 0000000000..f98cda7596 --- /dev/null +++ b/tests/auto/testlib/selftests/skipcleanup/skipcleanup.pro @@ -0,0 +1,7 @@ +SOURCES += tst_skipcleanup.cpp +QT = core testlib + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = skipcleanup diff --git a/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp b/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp new file mode 100644 index 0000000000..262aefa982 --- /dev/null +++ b/tests/auto/testlib/selftests/skipcleanup/tst_skipcleanup.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +class tst_SkipCleanup: public QObject +{ +Q_OBJECT +private slots: + void aTestFunction() const; + void cleanupTestCase() const; +}; + +void tst_SkipCleanup::aTestFunction() const +{ + QVERIFY(true); +} + +void tst_SkipCleanup::cleanupTestCase() const +{ + QSKIP("Skip inside cleanupTestCase."); +} + +QTEST_APPLESS_MAIN(tst_SkipCleanup) +#include "tst_skipcleanup.moc" diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index aaa58e092c..dc7966b82b 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -338,6 +338,7 @@ void tst_Selftests::runSubTest_data() << "exceptionthrow" #endif << "expectfail" + << "failcleanup" << "failinit" << "failinitdata" #if !defined(Q_OS_WIN) @@ -354,6 +355,7 @@ void tst_Selftests::runSubTest_data() << "qexecstringlist" << "singleskip" << "skip" + << "skipcleanup" << "skipinit" << "skipinitdata" << "sleep" -- cgit v1.2.3