Skip to content

Commit dc591b8

Browse files
committed
junit: Remove benchmark specific code from package junit
The junit package shouldn't need to know anything about benchmarks and gtr.Benchmark will be removed in a future commit. Instead, it will be the responsibility of the gotest parser to represent benchmarks using gtr.Test.
1 parent 46e0aed commit dc591b8

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

junit/junit.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ func CreateFromReport(report gtr.Report, hostname string) Testsuites {
160160
suite.AddTestcase(createTestcaseForTest(pkg.Name, test))
161161
}
162162

163-
for _, bm := range pkg.Benchmarks {
164-
suite.AddTestcase(createTestcaseForBenchmark(pkg.Name, bm))
165-
}
166-
167163
// JUnit doesn't have a good way of dealing with build or runtime
168164
// errors that happen before a test has started, so we create a single
169165
// failing test that contains the build error details.
@@ -231,29 +227,6 @@ func createTestcaseForTest(pkgName string, test gtr.Test) Testcase {
231227
return tc
232228
}
233229

234-
func createTestcaseForBenchmark(pkgName string, bm gtr.Benchmark) Testcase {
235-
tc := Testcase{
236-
Classname: pkgName,
237-
Name: bm.Name,
238-
Time: formatDuration(bm.ApproximateDuration()),
239-
}
240-
241-
if bm.Result == gtr.Fail {
242-
tc.Failure = &Result{
243-
Message: "Failed",
244-
Data: formatOutput(bm.Output, 0),
245-
}
246-
} else if bm.Result == gtr.Skip {
247-
tc.Skipped = &Result{
248-
Message: "Skipped",
249-
Data: formatOutput(bm.Output, 0),
250-
}
251-
} else if len(bm.Output) > 0 {
252-
tc.SystemOut = &Output{Data: formatOutput(bm.Output, 0)}
253-
}
254-
return tc
255-
}
256-
257230
// formatDuration returns the JUnit string representation of the given
258231
// duration.
259232
func formatDuration(d time.Duration) string {

junit/junit_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ func TestCreateFromReport(t *testing.T) {
1414
report := gtr.Report{
1515
Packages: []gtr.Package{
1616
{
17-
Benchmarks: []gtr.Benchmark{
17+
Tests: []gtr.Test{
1818
{
19-
Name: "BenchmarkFail",
19+
Name: "TestFail",
2020
Result: gtr.Fail,
2121
},
2222
},
@@ -35,7 +35,7 @@ func TestCreateFromReport(t *testing.T) {
3535
ID: 0,
3636
Testcases: []Testcase{
3737
{
38-
Name: "BenchmarkFail",
38+
Name: "TestFail",
3939
Time: "0.000",
4040
Failure: &Result{Message: "Failed"},
4141
},

0 commit comments

Comments
 (0)