diff options
Diffstat (limited to 'tests/auto/testlib/selftests')
17 files changed, 386 insertions, 17 deletions
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp index 97eb19599b..2cfe987f7d 100644 --- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp +++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp @@ -33,6 +33,9 @@ #include <QtGui/QColor> #include <QtGui/QImage> #include <QtGui/QPixmap> +#include <QtGui/QVector2D> +#include <QtGui/QVector3D> +#include <QtGui/QVector4D> #endif /* XPM test data for QPixmap, QImage tests (use drag cursors as example) */ @@ -144,6 +147,9 @@ private slots: void compareQImages_data(); void compareQRegion_data(); void compareQRegion(); + void compareQVector2D(); + void compareQVector3D(); + void compareQVector4D(); #endif void verify(); void verify2(); @@ -454,6 +460,33 @@ void tst_Cmptest::compareQRegion() QCOMPARE(rA, rB); } + +void tst_Cmptest::compareQVector2D() +{ + QVector2D v2a{1, 2}; + QVector2D v2b = v2a; + QCOMPARE(v2a, v2b); + v2b.setY(3); + QCOMPARE(v2a, v2b); +} + +void tst_Cmptest::compareQVector3D() +{ + QVector3D v3a{1, 2, 3}; + QVector3D v3b = v3a; + QCOMPARE(v3a, v3b); + v3b.setY(3); + QCOMPARE(v3a, v3b); +} + +void tst_Cmptest::compareQVector4D() +{ + QVector4D v4a{1, 2, 3, 4}; + QVector4D v4b = v4a; + QCOMPARE(v4a, v4b); + v4b.setY(3); + QCOMPARE(v4a, v4b); +} #endif // QT_GUI_LIB static int opaqueFunc() diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index 621aceb887..eb11d236d4 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -223,6 +223,30 @@ </Incident> <Duration msecs="0"/> </TestFunction> +<TestFunction name="compareQVector2D"> +<Incident type="fail" file="tst_cmptest.cpp" line="0"> + <Description><![CDATA[Compared values are not the same + Actual (v2a): QVector2D(1, 2) + Expected (v2b): QVector2D(1, 3)]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="compareQVector3D"> +<Incident type="fail" file="tst_cmptest.cpp" line="0"> + <Description><![CDATA[Compared values are not the same + Actual (v3a): QVector3D(1, 2, 3) + Expected (v3b): QVector3D(1, 3, 3)]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="compareQVector4D"> +<Incident type="fail" file="tst_cmptest.cpp" line="0"> + <Description><![CDATA[Compared values are not the same + Actual (v4a): QVector4D(1, 2, 3, 4) + Expected (v4b): QVector4D(1, 3, 3, 4)]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> <TestFunction name="verify"> <Incident type="fail" file="tst_cmptest.cpp" line="467"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> diff --git a/tests/auto/testlib/selftests/expected_cmptest.teamcity b/tests/auto/testlib/selftests/expected_cmptest.teamcity index f9cb5447d0..c49f5d6b79 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.teamcity +++ b/tests/auto/testlib/selftests/expected_cmptest.teamcity @@ -103,6 +103,15 @@ ##teamcity[testStarted name='compareQRegion(different lists)' flowId='tst_Cmptest'] ##teamcity[testFailed name='compareQRegion(different lists)' message='Failure! |[Loc: tst_cmptest.cpp(455)|]' details='Compared values are not the same|n Actual (rA): QRegion(200x50+10+10)|n Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)' flowId='tst_Cmptest'] ##teamcity[testFinished name='compareQRegion(different lists)' flowId='tst_Cmptest'] +##teamcity[testStarted name='compareQVector2D()' flowId='tst_Cmptest'] +##teamcity[testFailed name='compareQVector2D()' message='Failure! |[Loc: tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (v2a): QVector2D(1, 2)|n Expected (v2b): QVector2D(1, 3)' flowId='tst_Cmptest'] +##teamcity[testFinished name='compareQVector2D()' flowId='tst_Cmptest'] +##teamcity[testStarted name='compareQVector3D()' flowId='tst_Cmptest'] +##teamcity[testFailed name='compareQVector3D()' message='Failure! |[Loc: tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (v3a): QVector3D(1, 2, 3)|n Expected (v3b): QVector3D(1, 3, 3)' flowId='tst_Cmptest'] +##teamcity[testFinished name='compareQVector3D()' flowId='tst_Cmptest'] +##teamcity[testStarted name='compareQVector4D()' flowId='tst_Cmptest'] +##teamcity[testFailed name='compareQVector4D()' message='Failure! |[Loc: tst_cmptest.cpp(0)|]' details='Compared values are not the same|n Actual (v4a): QVector4D(1, 2, 3, 4)|n Expected (v4b): QVector4D(1, 3, 3, 4)' flowId='tst_Cmptest'] +##teamcity[testFinished name='compareQVector4D()' flowId='tst_Cmptest'] ##teamcity[testStarted name='verify()' flowId='tst_Cmptest'] ##teamcity[testFailed name='verify()' message='Failure! |[Loc: tst_cmptest.cpp(467)|]' details='|'opaqueFunc() < 2|' returned FALSE. ()' flowId='tst_Cmptest'] ##teamcity[testFinished name='verify()' flowId='tst_Cmptest'] diff --git a/tests/auto/testlib/selftests/expected_cmptest.txt b/tests/auto/testlib/selftests/expected_cmptest.txt index 9c7f56e6c3..179136a2c7 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.txt +++ b/tests/auto/testlib/selftests/expected_cmptest.txt @@ -111,6 +111,18 @@ FAIL! : tst_Cmptest::compareQRegion(different lists) Compared values are not th Actual (rA): QRegion(200x50+10+10) Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10) Loc: [tst_cmptest.cpp(455)] +FAIL! : tst_Cmptest::compareQVector2D() Compared values are not the same + Actual (v2a): QVector2D(1, 2) + Expected (v2b): QVector2D(1, 3) + Loc: [tst_cmptest.cpp(0)] +FAIL! : tst_Cmptest::compareQVector3D() Compared values are not the same + Actual (v3a): QVector3D(1, 2, 3) + Expected (v3b): QVector3D(1, 3, 3) + Loc: [tst_cmptest.cpp(0)] +FAIL! : tst_Cmptest::compareQVector4D() Compared values are not the same + Actual (v4a): QVector4D(1, 2, 3, 4) + Expected (v4b): QVector4D(1, 3, 3, 4) + Loc: [tst_cmptest.cpp(0)] FAIL! : tst_Cmptest::verify() 'opaqueFunc() < 2' returned FALSE. () Loc: [tst_cmptest.cpp(467)] FAIL! : tst_Cmptest::verify2() 'opaqueFunc() < 2' returned FALSE. (42) @@ -121,5 +133,5 @@ FAIL! : tst_Cmptest::tryVerify2() 'opaqueFunc() < 2' returned FALSE. (42) Loc: [tst_cmptest.cpp(485)] PASS : tst_Cmptest::verifyExplicitOperatorBool() PASS : tst_Cmptest::cleanupTestCase() -Totals: 15 passed, 30 failed, 0 skipped, 0 blacklisted, 244ms +Totals: 15 passed, 33 failed, 0 skipped, 0 blacklisted, 0ms ********* Finished testing of tst_Cmptest ********* diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index f64ffe3792..b281b04677 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -225,6 +225,30 @@ </Incident> <Duration msecs="0"/> </TestFunction> +<TestFunction name="compareQVector2D"> +<Incident type="fail" file="tst_cmptest.cpp" line="0"> + <Description><![CDATA[Compared values are not the same + Actual (v2a): QVector2D(1, 2) + Expected (v2b): QVector2D(1, 3)]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="compareQVector3D"> +<Incident type="fail" file="tst_cmptest.cpp" line="0"> + <Description><![CDATA[Compared values are not the same + Actual (v3a): QVector3D(1, 2, 3) + Expected (v3b): QVector3D(1, 3, 3)]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="compareQVector4D"> +<Incident type="fail" file="tst_cmptest.cpp" line="0"> + <Description><![CDATA[Compared values are not the same + Actual (v4a): QVector4D(1, 2, 3, 4) + Expected (v4b): QVector4D(1, 3, 3, 4)]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> <TestFunction name="verify"> <Incident type="fail" file="tst_cmptest.cpp" line="467"> <Description><![CDATA['opaqueFunc() < 2' returned FALSE. ()]]></Description> diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index de47ac97f5..c2c0c86058 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite errors="0" failures="30" tests="21" name="tst_Cmptest"> +<testsuite errors="0" failures="33" tests="24" name="tst_Cmptest"> <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> @@ -103,6 +103,21 @@ Actual (rA): QRegion(200x50+10+10) Expected (rB): QRegion(2 rectangles, 50x200+100+200, 200x50+10+10)" result="fail"/> </testcase> + <testcase result="fail" name="compareQVector2D"> + <failure message="Compared values are not the same + Actual (v2a): QVector2D(1, 2) + Expected (v2b): QVector2D(1, 3)" result="fail"/> + </testcase> + <testcase result="fail" name="compareQVector3D"> + <failure message="Compared values are not the same + Actual (v3a): QVector3D(1, 2, 3) + Expected (v3b): QVector3D(1, 3, 3)" result="fail"/> + </testcase> + <testcase result="fail" name="compareQVector4D"> + <failure message="Compared values are not the same + Actual (v4a): QVector4D(1, 2, 3, 4) + Expected (v4b): QVector4D(1, 3, 3, 4)" result="fail"/> + </testcase> <testcase result="fail" name="verify"> <failure message="'opaqueFunc() < 2' returned FALSE. ()" result="fail"/> </testcase> diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.lightxml b/tests/auto/testlib/selftests/expected_pairdiagnostics.lightxml new file mode 100644 index 0000000000..95b932e3c4 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.lightxml @@ -0,0 +1,30 @@ +<Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> +</Environment> +<TestFunction name="initTestCase"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="testQPair"> +<Incident type="fail" file="../../../qt5/qtbase_fixItemData/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp" line="51"> + <Description><![CDATA[Compared values are not the same + Actual (pair1): "QPair(1,1)" + Expected (pair2): "QPair(1,2)"]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="testStdPair"> +<Incident type="fail" file="../../../qt5/qtbase_fixItemData/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp" line="58"> + <Description><![CDATA[Compared values are not the same + Actual (pair1): "std::pair(1,1)" + Expected (pair2): "std::pair(1,2)"]]></Description> +</Incident> + <Duration msecs="0"/> +</TestFunction> +<TestFunction name="cleanupTestCase"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0"/> +</TestFunction> +<Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.teamcity b/tests/auto/testlib/selftests/expected_pairdiagnostics.teamcity new file mode 100644 index 0000000000..06883570ac --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.teamcity @@ -0,0 +1,12 @@ +##teamcity[testSuiteStarted name='tst_PairDiagnostics' flowId='tst_PairDiagnostics'] +##teamcity[testStarted name='initTestCase()' flowId='tst_PairDiagnostics'] +##teamcity[testFinished name='initTestCase()' flowId='tst_PairDiagnostics'] +##teamcity[testStarted name='testQPair()' flowId='tst_PairDiagnostics'] +##teamcity[testFailed name='testQPair()' message='Failure! |[Loc: ../../../qt5/qtbase_fixItemData/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp(51)|]' details='Compared values are not the same|n Actual (pair1): "QPair(1,1)"|n Expected (pair2): "QPair(1,2)"' flowId='tst_PairDiagnostics'] +##teamcity[testFinished name='testQPair()' flowId='tst_PairDiagnostics'] +##teamcity[testStarted name='testStdPair()' flowId='tst_PairDiagnostics'] +##teamcity[testFailed name='testStdPair()' message='Failure! |[Loc: ../../../qt5/qtbase_fixItemData/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp(58)|]' details='Compared values are not the same|n Actual (pair1): "std::pair(1,1)"|n Expected (pair2): "std::pair(1,2)"' flowId='tst_PairDiagnostics'] +##teamcity[testFinished name='testStdPair()' flowId='tst_PairDiagnostics'] +##teamcity[testStarted name='cleanupTestCase()' flowId='tst_PairDiagnostics'] +##teamcity[testFinished name='cleanupTestCase()' flowId='tst_PairDiagnostics'] +##teamcity[testSuiteFinished name='tst_PairDiagnostics' flowId='tst_PairDiagnostics'] diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.txt b/tests/auto/testlib/selftests/expected_pairdiagnostics.txt new file mode 100644 index 0000000000..e09b9a560f --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.txt @@ -0,0 +1,14 @@ +********* Start testing of tst_PairDiagnostics ********* +Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@ +PASS : tst_PairDiagnostics::initTestCase() +FAIL! : tst_PairDiagnostics::testQPair() Compared values are not the same + Actual (pair1): "QPair(1,1)" + Expected (pair2): "QPair(1,2)" + Loc: [../../../qt5/qtbase_fixItemData/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp(51)] +FAIL! : tst_PairDiagnostics::testStdPair() Compared values are not the same + Actual (pair1): "std::pair(1,1)" + Expected (pair2): "std::pair(1,2)" + Loc: [../../../qt5/qtbase_fixItemData/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp(58)] +PASS : tst_PairDiagnostics::cleanupTestCase() +Totals: 2 passed, 2 failed, 0 skipped, 0 blacklisted, 1ms +********* Finished testing of tst_PairDiagnostics ********* diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.xml b/tests/auto/testlib/selftests/expected_pairdiagnostics.xml new file mode 100644 index 0000000000..47921e0b8a --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<TestCase name="tst_PairDiagnostics"> +<Environment> + <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> + <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> +</Environment> +<TestFunction name="initTestCase"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0.680795"/> +</TestFunction> +<TestFunction name="testQPair"> +<Incident type="fail" file="../../../qt5/qtbase_fixItemData/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp" line="51"> + <Description><![CDATA[Compared values are not the same + Actual (pair1): "QPair(1,1)" + Expected (pair2): "QPair(1,2)"]]></Description> +</Incident> + <Duration msecs="0.085705"/> +</TestFunction> +<TestFunction name="testStdPair"> +<Incident type="fail" file="../../../qt5/qtbase_fixItemData/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp" line="58"> + <Description><![CDATA[Compared values are not the same + Actual (pair1): "std::pair(1,1)" + Expected (pair2): "std::pair(1,2)"]]></Description> +</Incident> + <Duration msecs="0.030780"/> +</TestFunction> +<TestFunction name="cleanupTestCase"> +<Incident type="pass" file="" line="0" /> + <Duration msecs="0.039052"/> +</TestFunction> +<Duration msecs="0.995227"/> +</TestCase> diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.xunitxml b/tests/auto/testlib/selftests/expected_pairdiagnostics.xunitxml new file mode 100644 index 0000000000..cf2a30b84a --- /dev/null +++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.xunitxml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<testsuite errors="0" failures="2" tests="4" name="tst_PairDiagnostics"> + <properties> + <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> + <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> + </properties> + <testcase result="pass" name="initTestCase"/> + <testcase result="fail" name="testQPair"> + <failure message="Compared values are not the same + Actual (pair1): "QPair(1,1)" + Expected (pair2): "QPair(1,2)"" result="fail"/> + </testcase> + <testcase result="fail" name="testStdPair"> + <failure message="Compared values are not the same + Actual (pair1): "std::pair(1,1)" + Expected (pair2): "std::pair(1,2)"" result="fail"/> + </testcase> + <testcase result="pass" name="cleanupTestCase"/> + <system-err/> +</testsuite> diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py index 202c4cc426..a3a66da98b 100755 --- a/tests/auto/testlib/selftests/generate_expected_output.py +++ b/tests/auto/testlib/selftests/generate_expected_output.py @@ -32,9 +32,18 @@ # Usage: cd to the build directory corresponding to this script's # location; invoke this script; optionally pass the names of sub-dirs # to limit which tests to regenerate expected_* files for. +# +# The saved test output is used by ./tst_selftests.cpp, which compares +# it to the output of each test, ignoring various boring changes. +# This script canonicalises the parts that would exhibit those boring +# changes, so as to avoid noise in git (and conflicts in merges) for +# the saved copies of the output. If you add or remove any files, be +# sure to update selftests.qrc to match; the selftest only sees files +# listed there. import os import subprocess +import re class Fail (Exception): pass @@ -55,17 +64,18 @@ class Cleaner (object): def __init__(self, here, command): """Set up the details we need for later cleaning. - Takes two parameters: here is $PWD and command is how this - script was invoked, from which we'll work out where it is; in - a shadow build, the former is the build tree's location - corresponding to this last. Checks $PWD does look as expected - in a build tree - raising Fail() if not - then invokes qmake - to discover Qt version (saved as .version for the benefit of - clients) and prepares the sequence of (regex, replace) pairs - that .clean() needs to do its job.""" - self.version, self.__replace = self.__getPatterns(here, command) - - import re + Takes two parameters: here is os.getcwd() and command is how + this script was invoked, from which we'll work out where it + is; in a shadow build, the former is the build tree's location + corresponding to this last. Saves the directory of this + script as self.sourceDir, so client can find tst_selftests.cpp + there. Checks here does look as expected in a build tree - + raising Fail() if not - then invokes qmake to discover Qt + version (saved as .version for the benefit of clients) and + prepares the sequence of (regex, replace) pairs that .clean() + needs to do its job.""" + self.version, self.sourceDir, self.__replace = self.__getPatterns(here, command) + @staticmethod def __getPatterns(here, command, patterns = ( @@ -80,9 +90,10 @@ class Cleaner (object): (r'( *<QtBuild)>[^<]+</QtBuild>', r'\1/>'), # xml, lightxml (r'(<property value=")[^"]+(" name="QtBuild"/>)', r'\1\2'), # xunitxml # Line numbers in source files: + (r'(ASSERT: ".*" in file .*, line) \d+', r'\1 0'), # lightxml (r'(Loc: \[[^[\]()]+)\(\d+\)', r'\1(0)'), # txt (r'(\[Loc: [^[\]()]+)\(\d+\)', r'\1(0)'), # teamcity - (r'(<Incident.*\bfile=.*\bline=)"\d+"', r'\1"0"'), # lightxml, xml + (r'(<(?:Incident|Message)\b.*\bfile=.*\bline=)"\d+"', r'\1"0"'), # lightxml, xml ), precook = re.compile): """Private implementation details of __init__().""" @@ -131,8 +142,7 @@ class Cleaner (object): patterns += tuple((root.replace('-', '�*2D;'), r'') for root in roots if '-' in root) - return qtver, tuple((precook(p), r) for p, r in patterns) - del re + return qtver, scriptPath, tuple((precook(p), r) for p, r in patterns) def clean(self, data): """Remove volatile details from test output. @@ -145,6 +155,62 @@ class Cleaner (object): line = searchRe.sub(replaceExp, line) yield line +class Scanner (object): + """Knows which subdirectories to generate output for. + + Tell its constructor the name of this source directory (see + Cleaner's .sourceDir) and it'll scan tst_selftests.cpp for the + list. Its .subdirs() can then filter a user-supplied list of + subdirs or generate the full list, when the user supplied + none.""" + def __init__(self, srcDir): + self.__tested = tuple(self.__scan_cpp(os.path.join(srcDir, 'tst_selftests.cpp'))) + + @staticmethod + def __scan_cpp(name, + trimc = re.compile(r'/\*.*?\*/').sub, + trimcpp = re.compile(r'//.*$').sub, + first = re.compile(r'(QStringList|auto)\s+tests\s*=\s*QStringList\(\)').match, + match = re.compile(r'(?:tests\s*)?<<\s*"(\w+)"').match, + last = re.compile(r'\bfor.*\b(LoggerSet|auto)\b.*\ballLoggerSets\(\)').search): + """Scans tst_selftests.cpp to find which subdirs matter. + + There's a list, tests, to which all subdir names get added, if + they're to be tested. Other sub-dirs aren't tested, so + there's no sense in generating output for them.""" + scan = False + with open(name) as src: + for line in src: + line = trimcpp('', trimc('', line.strip())).strip() + if not scan: + got = first(line) + if got: + scan, line = True, line[len(got.group()):] + if scan: + if last(line): break + got = match(line) + while got: + yield got.group(1) + line = line[len(got.group()):].strip() + got = match(line) + + def subdirs(self, given): + if given: + for d in given: + if not os.path.isdir(d): + print('No such directory:', d, '- skipped') + elif d in self.__tested: + yield d + else: + print('Directory', d, 'is not tested by tst_selftests.cpp') + else: + for d in self.__tested: + if os.path.isdir(d): + yield d + else: + print('tst_selftests.cpp names', d, "as a test, but it doesn't exist") +del re + def generateTestData(testname, clean, formats = ('xml', 'txt', 'xunitxml', 'lightxml', 'teamcity'), extraArgs = { @@ -190,7 +256,7 @@ def main(name, *args): herePath = os.getcwd() cleaner = Cleaner(herePath, name) - tests = args if args else [d for d in os.listdir('.') if os.path.isdir(d)] + tests = tuple(Scanner(cleaner.sourceDir).subdirs(args)) print("Generating", len(tests), "test results for", cleaner.version, "in:", herePath) for path in tests: generateTestData(path, cleaner.clean) diff --git a/tests/auto/testlib/selftests/pairdiagnostics/pairdiagnostics.pro b/tests/auto/testlib/selftests/pairdiagnostics/pairdiagnostics.pro new file mode 100644 index 0000000000..1c07c93e9d --- /dev/null +++ b/tests/auto/testlib/selftests/pairdiagnostics/pairdiagnostics.pro @@ -0,0 +1,6 @@ +SOURCES += tst_pairdiagnostics.cpp +QT = core testlib + +CONFIG -= app_bundle debug_and_release_target + +TARGET = pairdiagnostics diff --git a/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp b/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp new file mode 100644 index 0000000000..bbee5334fe --- /dev/null +++ b/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Make sure we get a real Q_ASSERT even in release builds +#ifdef QT_NO_DEBUG +# undef QT_NO_DEBUG +#endif + +#include <QtCore/QCoreApplication> +#include <QtCore/QPair> +#include <QtTest/QtTest> + +class tst_PairDiagnostics: public QObject +{ + Q_OBJECT + +private slots: + void testQPair() const; + void testStdPair() const; +}; + +void tst_PairDiagnostics::testQPair() const +{ + QPair<int, int> pair1 = qMakePair(1, 1); + QPair<int, int> pair2 = qMakePair(1, 2); + QCOMPARE(pair1, pair2); +} + +void tst_PairDiagnostics::testStdPair() const +{ + std::pair<int, int> pair1 = std::make_pair(1, 1); + std::pair<int, int> pair2 = std::make_pair(1, 2); + QCOMPARE(pair1, pair2); +} + +QTEST_MAIN(tst_PairDiagnostics) + +#include "tst_pairdiagnostics.moc" diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 66c7e06760..0287e35447 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -28,6 +28,7 @@ SUBPROGRAMS = \ longstring \ maxwarnings \ multiexec \ + pairdiagnostics \ printdatatags \ printdatatagswithglobaltags \ qexecstringlist \ diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc index 3c3fef28d9..02e8adb6b4 100644 --- a/tests/auto/testlib/selftests/selftests.qrc +++ b/tests/auto/testlib/selftests/selftests.qrc @@ -115,6 +115,11 @@ <file>expected_maxwarnings.xml</file> <file>expected_maxwarnings.xunitxml</file> <file>expected_multiexec.txt</file> + <file>expected_pairdiagnostics.lightxml</file> + <file>expected_pairdiagnostics.teamcity</file> + <file>expected_pairdiagnostics.txt</file> + <file>expected_pairdiagnostics.xml</file> + <file>expected_pairdiagnostics.xunitxml</file> <file>expected_printdatatags.txt</file> <file>expected_printdatatagswithglobaltags.txt</file> <file>expected_qexecstringlist.txt</file> diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index e7123fc059..64f324e26c 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -395,6 +395,7 @@ void tst_Selftests::runSubTest_data() << "longstring" << "maxwarnings" << "multiexec" + << "pairdiagnostics" << "printdatatags" << "printdatatagswithglobaltags" << "qexecstringlist" |