Skip to content

Commit d1bc77b

Browse files
committed
JSONReporter's listTests only lists class-name if it is non-empty
1 parent 5f00c57 commit d1bc77b

10 files changed

Lines changed: 5 additions & 18 deletions

benchmarks/discover_tests/listing_template.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"tests": [
99
{
1010
"name": "Comparing function pointers",
11-
"class-name": "",
1211
"tags": [
1312
"function pointer",
1413
"Tricky"
@@ -20,7 +19,6 @@
2019
},
2120
{
2221
"name": "Testing checked-if 4",
23-
"class-name": "",
2422
"tags": [
2523
"!shouldfail",
2624
"checked-if"
@@ -32,7 +30,6 @@
3230
},
3331
{
3432
"name": "count_equidistant_floats - double",
35-
"class-name": "",
3633
"tags": [
3734
"approvals",
3835
"distance",
@@ -45,7 +42,6 @@
4542
},
4643
{
4744
"name": "Usage of AllTrue range matcher",
48-
"class-name": "",
4945
"tags": [
5046
"matchers",
5147
"quantifiers",
@@ -58,7 +54,6 @@
5854
},
5955
{
6056
"name": "Exception matchers that succeed",
61-
"class-name": "",
6257
"tags": [
6358
"!throws",
6459
"exceptions",
@@ -83,7 +78,6 @@
8378
},
8479
{
8580
"name": "Approximate PI",
86-
"class-name": "",
8781
"tags": [
8882
"Approx",
8983
"PI"
@@ -95,7 +89,6 @@
9589
},
9690
{
9791
"name": "TextFlow::Column respects width setting",
98-
"class-name": "",
9992
"tags": [
10093
"approvals",
10194
"column",
@@ -108,7 +101,6 @@
108101
},
109102
{
110103
"name": "Generators internals",
111-
"class-name": "",
112104
"tags": [
113105
"generators",
114106
"internals"
@@ -120,7 +112,6 @@
120112
},
121113
{
122114
"name": "Mayfail test case with nested sections",
123-
"class-name": "",
124115
"tags": [
125116
"!mayfail"
126117
],

src/catch2/reporters/catch_reporter_json.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ namespace Catch {
360360
auto const& info = test.getTestCaseInfo();
361361

362362
desc_writer.write( "name"_sr ).write( info.name );
363-
desc_writer.write( "class-name"_sr ).write( info.className );
363+
if (!info.className.empty()) {
364+
desc_writer.write( "class-name"_sr ).write( info.className );
365+
}
364366
if ( m_listTags ) {
365367
auto tag_writer = desc_writer.write( "tags"_sr ).writeArray();
366368
for ( auto const& tag : info.tags ) {

tests/SelfTest/Baselines/compact.sw.approved.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,6 @@ Reporters.tests.cpp:<line number>: passed: listingString, ContainsSubstring( "fa
17381738
"tests": [
17391739
{
17401740
"name": "fake test name",
1741-
"class-name": "",
17421741
"tags": [
17431742
"fakeTestTag"
17441743
],

tests/SelfTest/Baselines/compact.sw.multi.approved.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,6 @@ Reporters.tests.cpp:<line number>: passed: listingString, ContainsSubstring( "fa
17361736
"tests": [
17371737
{
17381738
"name": "fake test name",
1739-
"class-name": "",
17401739
"tags": [
17411740
"fakeTestTag"
17421741
],

tests/SelfTest/Baselines/console.sw.approved.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11321,7 +11321,6 @@ with expansion:
1132111321
"tests": [
1132211322
{
1132311323
"name": "fake test name",
11324-
"class-name": "",
1132511324
"tags": [
1132611325
"fakeTestTag"
1132711326
],

tests/SelfTest/Baselines/console.sw.multi.approved.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11319,7 +11319,6 @@ with expansion:
1131911319
"tests": [
1132011320
{
1132111321
"name": "fake test name",
11322-
"class-name": "",
1132311322
"tags": [
1132411323
"fakeTestTag"
1132511324
],

tests/SelfTest/Baselines/tap.sw.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2775,7 +2775,7 @@ ok {test-number} - listingString, ContainsSubstring("fake reporter"s) for: "{
27752775
# Reporter's write listings to provided stream
27762776
ok {test-number} - !(factories.empty()) for: !false
27772777
# Reporter's write listings to provided stream
2778-
ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "{ "version": 2, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "<version>" }, "listings": { "tests": [ { "name": "fake test name", "class-name": "", "tags": [ "fakeTestTag" ], "source-location": { "filename": "fake-file.cpp", "line": 123456789 } } ]" ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: JSON'
2778+
ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "{ "version": 2, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "<version>" }, "listings": { "tests": [ { "name": "fake test name", "tags": [ "fakeTestTag" ], "source-location": { "filename": "fake-file.cpp", "line": 123456789 } } ]" ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: JSON'
27792779
# Reporter's write listings to provided stream
27802780
ok {test-number} - !(factories.empty()) for: !false
27812781
# Reporter's write listings to provided stream

tests/SelfTest/Baselines/tap.sw.multi.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2773,7 +2773,7 @@ ok {test-number} - listingString, ContainsSubstring("fake reporter"s) for: "{
27732773
# Reporter's write listings to provided stream
27742774
ok {test-number} - !(factories.empty()) for: !false
27752775
# Reporter's write listings to provided stream
2776-
ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "{ "version": 2, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "<version>" }, "listings": { "tests": [ { "name": "fake test name", "class-name": "", "tags": [ "fakeTestTag" ], "source-location": { "filename": "fake-file.cpp", "line": 123456789 } } ]" ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: JSON'
2776+
ok {test-number} - listingString, ContainsSubstring( "fake test name"s ) && ContainsSubstring( "fakeTestTag"s ) for: "{ "version": 2, "metadata": { "name": "", "rng-seed": 1234, "catch2-version": "<version>" }, "listings": { "tests": [ { "name": "fake test name", "tags": [ "fakeTestTag" ], "source-location": { "filename": "fake-file.cpp", "line": 123456789 } } ]" ( contains: "fake test name" and contains: "fakeTestTag" ) with 1 message: 'Tested reporter: JSON'
27772777
# Reporter's write listings to provided stream
27782778
ok {test-number} - !(factories.empty()) for: !false
27792779
# Reporter's write listings to provided stream

tests/SelfTest/Baselines/xml.sw.approved.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13501,7 +13501,6 @@ Approx( 0.98999999999999999 )
1350113501
"tests": [
1350213502
{
1350313503
"name": "fake test name",
13504-
"class-name": "",
1350513504
"tags": [
1350613505
"fakeTestTag"
1350713506
],

tests/SelfTest/Baselines/xml.sw.multi.approved.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13501,7 +13501,6 @@ Approx( 0.98999999999999999 )
1350113501
"tests": [
1350213502
{
1350313503
"name": "fake test name",
13504-
"class-name": "",
1350513504
"tags": [
1350613505
"fakeTestTag"
1350713506
],

0 commit comments

Comments
 (0)