From 5e3d821814459507eead2945436cbff9f5e09d45 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Fri, 5 Jul 2024 14:29:22 +0200 Subject: [PATCH] pkg/machine/e2e: print tests timings at the end Makes it easier to see which tests are slow. Signed-off-by: Paul Holzinger --- pkg/machine/e2e/machine_test.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/machine/e2e/machine_test.go b/pkg/machine/e2e/machine_test.go index 3f7415d870..d825bf7bbc 100644 --- a/pkg/machine/e2e/machine_test.go +++ b/pkg/machine/e2e/machine_test.go @@ -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