diff options
author | jasplin <jo.asplin@nokia.com> | 2011-06-08 15:13:13 (GMT) |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-07-26 04:18:56 (GMT) |
commit | 01575deafb7d26ca2431374e92c6d71de96547c7 (patch) | |
tree | aa8499a652c4abfb5a1ec98e48612b133f0c2fdf /tests/auto/selftests | |
parent | 13ea186f3592815899f0cecc07a6094e2360a71e (diff) | |
download | Qt-01575deafb7d26ca2431374e92c6d71de96547c7.zip Qt-01575deafb7d26ca2431374e92c6d71de96547c7.tar.gz Qt-01575deafb7d26ca2431374e92c6d71de96547c7.tar.bz2 |
Added -datatags option to QTestLib
Passing the -datatags option to a QTestLib program prints the available
data tags to standard output.
Data tags for each test function (f() in this case) are printed in
four different ways depending on the presence of local and global
data tags:
Case 1: No tags:
f()
Case 2: Local tags only:
f() local tag 1
f() local tag 2
...
Case 3: Global tags only:
f() __global__ global tag 1
f() __global__ global tag 2
...
Case 4: Local and global tags:
f() local tag 1 __global__ global tag 1
f() local tag 2 __global__ global tag 1
...
f() local tag 1 __global__ global tag 2
f() local tag 2 __global__ global tag 2
...
...
Reviewed-by: Rohan McGovern
Task-number: QTQAINFRA-226
Change-Id: I14de203b586a0085b8efda8e62772711e44677d2
Diffstat (limited to 'tests/auto/selftests')
9 files changed, 164 insertions, 1 deletions
diff --git a/tests/auto/selftests/expected_printdatatags.txt b/tests/auto/selftests/expected_printdatatags.txt new file mode 100644 index 0000000..02390dc --- /dev/null +++ b/tests/auto/selftests/expected_printdatatags.txt @@ -0,0 +1,6 @@ +a() data tag a1 +a() data tag a2 +b() +c() data tag c1 +c() data tag c2 +c() data tag c3 diff --git a/tests/auto/selftests/expected_printdatatagswithglobaltags.txt b/tests/auto/selftests/expected_printdatatagswithglobaltags.txt new file mode 100644 index 0000000..a91e1b8 --- /dev/null +++ b/tests/auto/selftests/expected_printdatatagswithglobaltags.txt @@ -0,0 +1,12 @@ +a() data tag a1 __global__ global data tag 1 +a() data tag a2 __global__ global data tag 1 +a() data tag a1 __global__ global data tag 2 +a() data tag a2 __global__ global data tag 2 +b() __global__ global data tag 1 +b() __global__ global data tag 2 +c() data tag c1 __global__ global data tag 1 +c() data tag c2 __global__ global data tag 1 +c() data tag c3 __global__ global data tag 1 +c() data tag c1 __global__ global data tag 2 +c() data tag c2 __global__ global data tag 2 +c() data tag c3 __global__ global data tag 2 diff --git a/tests/auto/selftests/printdatatags/printdatatags.pro b/tests/auto/selftests/printdatatags/printdatatags.pro new file mode 100644 index 0000000..a134422 --- /dev/null +++ b/tests/auto/selftests/printdatatags/printdatatags.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +SOURCES += tst_printdatatags.cpp +QT = core + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = printdatatags diff --git a/tests/auto/selftests/printdatatags/tst_printdatatags.cpp b/tests/auto/selftests/printdatatags/tst_printdatatags.cpp new file mode 100644 index 0000000..fe4bcf0 --- /dev/null +++ b/tests/auto/selftests/printdatatags/tst_printdatatags.cpp @@ -0,0 +1,48 @@ +#include <QtTest/QtTest> + +class tst_Foo: public QObject +{ + Q_OBJECT +private slots: + void a_data() const; + void a() const; + + void b() const; + + void c_data() const; + void c() const; +}; + +void tst_Foo::a_data() const +{ + QTest::addColumn<int>("x"); + QTest::addColumn<int>("y"); + + QTest::newRow("data tag a1 ") << 1 << 2; + QTest::newRow("data tag a2") << 1 << 2; +} + +void tst_Foo::a() const +{ +} + +void tst_Foo::b() const +{ +} + +void tst_Foo::c_data() const +{ + QTest::addColumn<int>("x"); + + QTest::newRow("data tag c1") << 1; + QTest::newRow("data tag c2") << 1; + QTest::newRow("data tag c3") << 1; +} + +void tst_Foo::c() const +{ +} + +QTEST_MAIN(tst_Foo) + +#include "tst_printdatatags.moc" diff --git a/tests/auto/selftests/printdatatagswithglobaltags/printdatatagswithglobaltags.pro b/tests/auto/selftests/printdatatagswithglobaltags/printdatatagswithglobaltags.pro new file mode 100644 index 0000000..100ba1c --- /dev/null +++ b/tests/auto/selftests/printdatatagswithglobaltags/printdatatagswithglobaltags.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +SOURCES += tst_printdatatagswithglobaltags.cpp +QT = core + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + +TARGET = printdatatagswithglobaltags diff --git a/tests/auto/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp b/tests/auto/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp new file mode 100644 index 0000000..cc58bec --- /dev/null +++ b/tests/auto/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp @@ -0,0 +1,64 @@ +#include <QtTest/QtTest> + +class tst_Foo: public QObject +{ + Q_OBJECT +private slots: + void initTestCase_data() const; + void initTestCase() const; + + void a_data() const; + void a() const; + + void b() const; + + void c_data() const; + void c() const; +}; + +void tst_Foo::initTestCase_data() const +{ + QTest::addColumn<int>("f"); + QTest::addColumn<int>("g"); + + QTest::newRow("global data tag 1 ") << 1 << 2; + QTest::newRow("global data tag 2") << 1 << 2; +} + +void tst_Foo::initTestCase() const +{ +} + +void tst_Foo::a_data() const +{ + QTest::addColumn<int>("x"); + QTest::addColumn<int>("y"); + + QTest::newRow("data tag a1 ") << 1 << 2; + QTest::newRow("data tag a2") << 1 << 2; +} + +void tst_Foo::a() const +{ +} + +void tst_Foo::b() const +{ +} + +void tst_Foo::c_data() const +{ + QTest::addColumn<int>("x"); + + QTest::newRow("data tag c1") << 1; + QTest::newRow("data tag c2") << 1; + QTest::newRow("data tag c3") << 1; +} + +void tst_Foo::c() const +{ +} + +QTEST_MAIN(tst_Foo) + +#include "tst_printdatatagswithglobaltags.moc" diff --git a/tests/auto/selftests/selftests.pro b/tests/auto/selftests/selftests.pro index 2f1c327..74cd075 100644 --- a/tests/auto/selftests/selftests.pro +++ b/tests/auto/selftests/selftests.pro @@ -5,7 +5,8 @@ SUBDIRS = subtest test warnings maxwarnings cmptest globaldata skipglobal skip \ skipinit skipinitdata datetime singleskip assert waitwithoutgui differentexec \ exceptionthrow qexecstringlist datatable commandlinedata\ benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \ - benchliboptions xunit badxml longstring + benchliboptions xunit badxml longstring printdatatags \ + printdatatagswithglobaltags INSTALLS = diff --git a/tests/auto/selftests/selftests.qrc b/tests/auto/selftests/selftests.qrc index f82722b..5bd0e12 100644 --- a/tests/auto/selftests/selftests.qrc +++ b/tests/auto/selftests/selftests.qrc @@ -89,6 +89,8 @@ <file>expected_multiexec.txt</file> <file>expected_multiexec.xml</file> <file>expected_multiexec.xunitxml</file> + <file>expected_printdatatags.txt</file> + <file>expected_printdatatagswithglobaltags.txt</file> <file>expected_qexecstringlist.txt</file> <file>expected_singleskip.lightxml</file> <file>expected_singleskip.txt</file> diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 1a95420..3686304 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -245,6 +245,8 @@ void tst_Selftests::runSubTest_data() << "xunit" << "longstring" << "badxml" + << "printdatatags" + << "printdatatagswithglobaltags" ; foreach (Logger const& logger, allLoggers()) { @@ -273,6 +275,12 @@ void tst_Selftests::runSubTest_data() else if (subtest == "badxml") { arguments << "-eventcounter"; } + else if (subtest == "printdatatags") { + arguments << "-datatags"; + } + else if (subtest == "printdatatagswithglobaltags") { + arguments << "-datatags"; + } // These tests don't work right with loggers other than plain, usually because // they internally supply arguments to themselves. @@ -289,6 +297,12 @@ void tst_Selftests::runSubTest_data() if (subtest == "waitwithoutgui") { continue; } + if (subtest == "printdatatags") { + continue; + } + if (subtest == "printdatatagswithglobaltags") { + continue; + } // `crashes' will not output valid XML on platforms without a crash handler if (subtest == "crashes") { continue; |