Skip to content

Commit f3a36b6

Browse files
Mic92onsi
authored andcommitted
Add ArtifactDir() to support Go 1.26 testing.TB interface
Go 1.26 added ArtifactDir() string to the testing.TB interface. This adds the method to GinkgoTInterface, GinkgoTBWrapper, and ginkgoTestingTProxy to maintain compatibility. Fixes #1640
1 parent 94151c8 commit f3a36b6

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

ginkgo_t_dsl.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type GinkgoTInterface interface {
7272
TempDir() string
7373
Attr(key, value string)
7474
Output() io.Writer
75+
ArtifactDir() string
7576
}
7677

7778
/*
@@ -196,3 +197,6 @@ func (g *GinkgoTBWrapper) Attr(key, value string) {
196197
func (g *GinkgoTBWrapper) Output() io.Writer {
197198
return g.GinkgoT.Output()
198199
}
200+
func (g *GinkgoTBWrapper) ArtifactDir() string {
201+
return g.GinkgoT.ArtifactDir()
202+
}

internal/testingtproxy/testing_t_proxy.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ func (t *ginkgoTestingTProxy) TempDir() string {
181181
return tmpDir
182182
}
183183

184+
func (t *ginkgoTestingTProxy) ArtifactDir() string {
185+
artifactDir, err := os.MkdirTemp("", "ginkgo")
186+
if err != nil {
187+
t.fail(fmt.Sprintf("Failed to create artifact directory: %v", err), 1)
188+
return ""
189+
}
190+
return artifactDir
191+
}
192+
184193
// FullGinkgoTInterface
185194
func (t *ginkgoTestingTProxy) AddReportEntryVisibilityAlways(name string, args ...any) {
186195
finalArgs := []any{internal.Offset(1), types.ReportEntryVisibilityAlways}

0 commit comments

Comments
 (0)