pkg/machine/e2e: print tests timings at the end

Makes it easier to see which tests are slow.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2024-07-05 14:29:22 +02:00
parent 527c0f0bfa
commit 5e3d821814
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
1 changed files with 26 additions and 1 deletions

View File

@ -1,13 +1,16 @@
package e2e_test
import (
"cmp"
"errors"
"fmt"
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"testing"
"time"
"github.com/containers/common/pkg/config"
"github.com/containers/podman/v5/pkg/machine/define"
@ -75,7 +78,29 @@ var _ = BeforeSuite(func() {
}
})
var _ = SynchronizedAfterSuite(func() {}, func() {})
type timing struct {
name string
length time.Duration
}
var timings []timing
var _ = AfterEach(func() {
r := CurrentSpecReport()
timings = append(timings, timing{
name: r.FullText(),
length: r.RunTime,
})
})
var _ = SynchronizedAfterSuite(func() {}, func() {
slices.SortFunc(timings, func(a, b timing) int {
return cmp.Compare(a.length, b.length)
})
for _, t := range timings {
GinkgoWriter.Printf("%s\t\t%f seconds\n", t.name, t.length.Seconds())
}
})
func setup() (string, *machineTestBuilder) {
// Set TMPDIR if this needs a new directory