Added -datatags option to QTestLib
authorJo Asplin <jo.asplin@nokia.com>
Tue, 1 Nov 2011 11:19:39 +0000 (12:19 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 4 Nov 2011 18:23:33 +0000 (19:23 +0100)
commitb68bae1132b5dc5c8f55435c72cd48e24aa52ec9
tree0b8a6bbed8b86d5aeed7c8f725dff4d01d593da2
parent456236b8c8fb90ddbb7812a4bb200a37d2318757
Added -datatags option to QTestLib

(Note: This feature is ported from Qt 4.8.
 See the following commits:
  01575deafb7d26ca2431374e92c6d71de96547c7
  4866d1ba8afbab61e102942d1ea93b81fea053d6
)

Passing the -datatags option to a QTestLib program prints the
available data tags to standard output.

For completeness, the test case name is also printed
at the start of each output line. (Although the file name
is supposed to match the lower-case version of the test case
name, this is currently not true in all cases (particularly not
under tests/benchmarks/). Even if there was a script to enforce this
convention, the -datatags option provides this information in a
reliable way.)

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:
    tst_MyTestCasetst_MyTestCase f

Case 2: Local tags only:
    tst_MyTestCase f local tag 1
    tst_MyTestCase f local tag 2
    ...

Case 3: Global tags only:
    tst_MyTestCase f __global__ global tag 1
    tst_MyTestCase f __global__ global tag 2
    ...

Case 4: Local and global tags:
    tst_MyTestCase f local tag 1 __global__ global tag 1
    tst_MyTestCase f local tag 2 __global__ global tag 1
    ...
    tst_MyTestCase f local tag 1 __global__ global tag 2
    tst_MyTestCase f local tag 2 __global__ global tag 2
    ...
    ...

Note that the string __global__ is assumed to be highly unlikely to occur
in a data tag (if it does, an ambiguity results).

Change-Id: Ib51aa0c3c32ad52e52ce519729292cf8f0ec5d50
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
12 files changed:
src/testlib/qtestcase.cpp
src/testlib/qtestlog.cpp
src/testlib/qtestlog_p.h
tests/auto/testlib/selftests/expected_printdatatags.txt [new file with mode: 0644]
tests/auto/testlib/selftests/expected_printdatatagswithglobaltags.txt [new file with mode: 0644]
tests/auto/testlib/selftests/printdatatags/printdatatags.pro [new file with mode: 0644]
tests/auto/testlib/selftests/printdatatags/tst_printdatatags.cpp [new file with mode: 0644]
tests/auto/testlib/selftests/printdatatagswithglobaltags/printdatatagswithglobaltags.pro [new file with mode: 0644]
tests/auto/testlib/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp [new file with mode: 0644]
tests/auto/testlib/selftests/selftests.pro
tests/auto/testlib/selftests/selftests.qrc
tests/auto/testlib/selftests/tst_selftests.cpp