From 65e2c93da045228f26b7c079cccd5f1b90670d31 Mon Sep 17 00:00:00 2001 From: Konboi Date: Mon, 16 Jun 2025 16:37:51 +0900 Subject: [PATCH 1/2] support subtest case --- launchable/test_runners/go_test.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/launchable/test_runners/go_test.py b/launchable/test_runners/go_test.py index c71eb4e87..8f148be4e 100644 --- a/launchable/test_runners/go_test.py +++ b/launchable/test_runners/go_test.py @@ -61,11 +61,23 @@ def record_tests(client, source_roots): def path_builder(case: TestCase, suite: TestSuite, report_file: str) -> TestPath: tp = default_path_builder(case, suite, report_file) for tpc in tp: - if 'type' in tpc and 'name' in tpc and tpc['type'] == 'class': - # go-junit-report v2 reports full package name. go-junit-report - # v1 reports only the last component of the package name. In - # order to make this backward compatible, we align this to v1. - tpc['name'] = tpc['name'].split('/')[-1] + if 'type' in tpc and 'name' in tpc: + if tpc['type'] == 'class': + # go-junit-report v2 reports full package name. go-junit-report + # v1 reports only the last component of the package name. In + # order to make this backward compatible, we align this to v1. + tpc['name'] = tpc['name'].split('/')[-1] + if tpc['type'] == 'testcase' and '/' in tpc['name']: + # go-junit-report produces test with subtests like `` + # But `go test -list` command doesn't include subtest names + # So, we split the name by '/' and save testcase and subtest + names = tpc['name'].split('/') + tpc['name'] = names[0] + tp.append({ + 'type': 'subtest', + 'name': '/'.join(names[1:]) if len(names) > 1 else '' + }) + return tp client.path_builder = path_builder From 9be5e1b4e24442e4799b264510fb3d85b3d395b8 Mon Sep 17 00:00:00 2001 From: Konboi Date: Mon, 16 Jun 2025 16:41:46 +0900 Subject: [PATCH 2/2] update test data --- tests/data/go_test/record_test_result.json | 110 +++++++++++++++++++-- tests/data/go_test/reportv1/reportv1.xml | 22 +++-- tests/data/go_test/reportv2/reportv2.xml | 21 ++-- 3 files changed, 134 insertions(+), 19 deletions(-) diff --git a/tests/data/go_test/record_test_result.json b/tests/data/go_test/record_test_result.json index dfacaebcf..96d42d6e9 100644 --- a/tests/data/go_test/record_test_result.json +++ b/tests/data/go_test/record_test_result.json @@ -5,7 +5,7 @@ "testPath": [ { "type": "class", - "name": "rocket-car-gotest" + "name": "go" }, { "type": "testcase", @@ -23,7 +23,7 @@ "testPath": [ { "type": "class", - "name": "rocket-car-gotest" + "name": "go" }, { "type": "testcase", @@ -41,7 +41,7 @@ "testPath": [ { "type": "class", - "name": "rocket-car-gotest" + "name": "go" }, { "type": "testcase", @@ -59,7 +59,7 @@ "testPath": [ { "type": "class", - "name": "rocket-car-gotest" + "name": "go" }, { "type": "testcase", @@ -71,11 +71,109 @@ "stdout": "", "stderr": "", "data": null + }, + { + "type": "case", + "testPath": [ + { + "type": "class", + "name": "go" + }, + { + "type": "testcase", + "name": "TestExample5" + } + ], + "duration": 0.0, + "status": 1, + "stdout": "", + "stderr": "", + "data": null + }, + { + "type": "case", + "testPath": [ + { + "type": "class", + "name": "go" + }, + { + "type": "testcase", + "name": "TestExample5" + }, + { + "type": "subtest", + "name": "Test_case_1" + } + ], + "duration": 0.0, + "status": 1, + "stdout": "", + "stderr": "", + "data": null + }, + { + "type": "case", + "testPath": [ + { + "type": "class", + "name": "go" + }, + { + "type": "testcase", + "name": "TestExample5" + }, + { + "type": "subtest", + "name": "Test_case_2_(fail_case)" + } + ], + "duration": 0.0, + "status": 1, + "stdout": "", + "stderr": "", + "data": null + }, + { + "type": "case", + "testPath": [ + { + "type": "class", + "name": "example" + }, + { + "type": "testcase", + "name": "TestGreeting" + } + ], + "duration": 0.0, + "status": 1, + "stdout": "", + "stderr": "", + "data": null + }, + { + "type": "case", + "testPath": [ + { + "type": "class", + "name": "example" + }, + { + "type": "testcase", + "name": "ExampleGreeting" + } + ], + "duration": 0.0, + "status": 1, + "stdout": "", + "stderr": "", + "data": null } ], "testRunner": "go-test", "group": "", "noBuild": false, - "flavors": [], - "testSuite": "" + "testSuite": "", + "flavors": {} } diff --git a/tests/data/go_test/reportv1/reportv1.xml b/tests/data/go_test/reportv1/reportv1.xml index 26c9fe603..31fe7cabb 100644 --- a/tests/data/go_test/reportv1/reportv1.xml +++ b/tests/data/go_test/reportv1/reportv1.xml @@ -1,12 +1,22 @@ - + - + - - - - + + + + + + + + + + + + + + diff --git a/tests/data/go_test/reportv2/reportv2.xml b/tests/data/go_test/reportv2/reportv2.xml index 82717b8a8..e207ab73b 100644 --- a/tests/data/go_test/reportv2/reportv2.xml +++ b/tests/data/go_test/reportv2/reportv2.xml @@ -1,9 +1,16 @@ - - - - - - - + + + + + + + + + + + + + +