Skip to content

Commit

Permalink
testlib: Accurately name JUnit test, and only run for JUnitXML reporter
Browse files Browse the repository at this point in the history
The JUnit reporter was initially named xunit, but the naming was inaccurate
and the reporter was renamed in 27db9e4.

The corresponding test has now been renamed as well, and as an added bonus
we only run it for that reporter.

Pick-to: 6.2
Change-Id: I59cb7d949514cdf46a0199a53a7a3e39f833207c
Reviewed-by: Mårten Nordheim <[email protected]>
Reviewed-by: Friedemann Kleint <[email protected]>
  • Loading branch information
torarnv committed Jul 29, 2021
1 parent 08a1bcf commit edba9cd
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 265 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ __pycache__
/tests/auto/testlib/selftests/verifyexceptionthrown/verifyexceptionthrown
/tests/auto/testlib/selftests/waitwithoutgui/waitwithoutgui
/tests/auto/testlib/selftests/warnings/warnings
/tests/auto/testlib/selftests/xunit/xunit
/tests/auto/testlib/selftests/junit/junit
/tests/auto/widgets/kernel/qapplication/modal/modal

QObject.log
Expand Down
2 changes: 1 addition & 1 deletion tests/auto/testlib/selftests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ set(subprograms
findtestdata
float
globaldata
junit
longstring
maxwarnings
multiexec
Expand All @@ -116,7 +117,6 @@ set(subprograms
verifyexceptionthrown
warnings
watchdog
xunit
)

if(TARGET Qt::Gui)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite name="tst_Xunit" timestamp="@TEST_START_TIME@" tests="9" failures="3" errors="5" time="@TEST_DURATION@">
<testsuite name="tst_JUnit" timestamp="@TEST_START_TIME@" tests="9" failures="3" errors="5" time="@TEST_DURATION@">
<properties>
<property name="QTestVersion" value="@INSERT_QT_VERSION_HERE@"/>
<property name="QtVersion" value="@INSERT_QT_VERSION_HERE@"/>
Expand Down
64 changes: 0 additions & 64 deletions tests/auto/testlib/selftests/expected_xunit.lightxml

This file was deleted.

44 changes: 0 additions & 44 deletions tests/auto/testlib/selftests/expected_xunit.tap

This file was deleted.

26 changes: 0 additions & 26 deletions tests/auto/testlib/selftests/expected_xunit.teamcity

This file was deleted.

26 changes: 0 additions & 26 deletions tests/auto/testlib/selftests/expected_xunit.txt

This file was deleted.

67 changes: 0 additions & 67 deletions tests/auto/testlib/selftests/expected_xunit.xml

This file was deleted.

4 changes: 3 additions & 1 deletion tests/auto/testlib/selftests/generate_expected_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
'signaldumper', 'silent', 'singleskip', 'skip', 'skipcleanup',
'skipinit', 'skipinitdata', 'sleep', 'strcmp', 'subtest', 'testlib',
'tuplediagnostics', 'verbose1', 'verbose2', 'verifyexceptionthrown',
'warnings', 'watchdog', 'xunit', 'keyboard']
'warnings', 'watchdog', 'junit', 'keyboard']


class Fail (Exception): pass
Expand Down Expand Up @@ -306,6 +306,8 @@ def generateTestData(test_path, expected_path, clean, formats):
env = testEnv(testname)

for format in formats:
if testname == "junit" and not format == "junitxml":
continue
print(f' running {testname}/{format}')
cmd = [path, f'-{format}']
expected_file = f'expected_{testname}.{format}'
Expand Down
11 changes: 11 additions & 0 deletions tests/auto/testlib/selftests/junit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

qt_internal_add_executable(junit
NO_INSTALL # special case
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case
SOURCES
tst_junit.cpp
PUBLIC_LIBRARIES
Qt::Test
)

qt_internal_apply_testlib_coverage_options(junit)
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

#include <QTest>

class tst_Xunit : public QObject
class tst_JUnit : public QObject
{
Q_OBJECT

public:
tst_Xunit();
tst_JUnit();

private slots:
void testFunc1();
Expand All @@ -45,28 +45,28 @@ private slots:
void testFunc7();
};

tst_Xunit::tst_Xunit()
tst_JUnit::tst_JUnit()
{
}

void tst_Xunit::testFunc1()
void tst_JUnit::testFunc1()
{
QWARN("just a QWARN() !");
QCOMPARE(1,1);
}

void tst_Xunit::testFunc2()
void tst_JUnit::testFunc2()
{
qDebug("a qDebug() call with comment-ending stuff -->");
QCOMPARE(2, 3);
}

void tst_Xunit::testFunc3()
void tst_JUnit::testFunc3()
{
QSKIP("skipping this function!");
}

void tst_Xunit::testFunc4()
void tst_JUnit::testFunc4()
{
QFAIL("a forced failure!");
}
Expand All @@ -79,24 +79,24 @@ void tst_Xunit::testFunc4()
count.
*/

void tst_Xunit::testFunc5()
void tst_JUnit::testFunc5()
{
QEXPECT_FAIL("", "this failure is expected", Abort);
QVERIFY(false);
}

void tst_Xunit::testFunc6()
void tst_JUnit::testFunc6()
{
QEXPECT_FAIL("", "this failure is also expected", Abort);
QFAIL("This is a deliberate failure");
}

void tst_Xunit::testFunc7()
void tst_JUnit::testFunc7()
{
QEXPECT_FAIL("", "this pass is unexpected", Abort);
QVERIFY(true);
}


QTEST_APPLESS_MAIN(tst_Xunit)
#include "tst_xunit.moc"
QTEST_APPLESS_MAIN(tst_JUnit)
#include "tst_junit.moc"
5 changes: 4 additions & 1 deletion tests/auto/testlib/selftests/tst_selftests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,9 @@ bool TestLogger::shouldIgnoreTest(const QString &test) const
if (logger == QTestLog::TeamCity && test.startsWith("benchlib"))
return true; // Skip benchmark for TeamCity logger

if (logger != QTestLog::JUnitXML && test == "junit")
return true;

return false;
}

Expand Down Expand Up @@ -775,7 +778,7 @@ void checkErrorOutput(const QString &test, const QByteArray &errorOutput)
|| test == "cmptest" // QImage comparison requires QGuiApplication
|| test == "fetchbogus"
|| test == "watchdog"
|| test == "xunit"
|| test == "junit"
|| test == "benchlibcallgrind")
return;

Expand Down
Loading

0 comments on commit edba9cd

Please sign in to comment.