Skip to content

Commit b08bd53

Browse files
authored
Merge pull request kubernetes-sigs#6799 from chrischdi/pr-make-test-create-artifacts-dir
🐛 Improve TestE2E error output and create artifacts dir if not exists
2 parents 612b1e5 + 01c7adb commit b08bd53

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/e2e/e2e_suite_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,21 @@ func init() {
9292
}
9393

9494
func TestE2E(t *testing.T) {
95+
g := NewWithT(t)
96+
9597
// If running in prow, make sure to use the artifacts folder that will be reported in test grid (ignoring the value provided by flag).
9698
if prowArtifactFolder, exists := os.LookupEnv("ARTIFACTS"); exists {
9799
artifactFolder = prowArtifactFolder
98100
}
99101

102+
// ensure the artifacts folder exists
103+
g.Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder) //nolint:gosec
104+
100105
RegisterFailHandler(Fail)
101106

102107
if alsoLogToFile {
103108
w, err := ginkgoextensions.EnableFileLogging(filepath.Join(artifactFolder, "ginkgo-log.txt"))
104-
Expect(err).ToNot(HaveOccurred())
109+
g.Expect(err).ToNot(HaveOccurred())
105110
defer w.Close()
106111
}
107112

@@ -115,7 +120,6 @@ var _ = SynchronizedBeforeSuite(func() []byte {
115120
// Before all ParallelNodes.
116121

117122
Expect(configPath).To(BeAnExistingFile(), "Invalid test suite argument. e2e.config should be an existing file.")
118-
Expect(os.MkdirAll(artifactFolder, 0755)).To(Succeed(), "Invalid test suite argument. Can't create e2e.artifacts-folder %q", artifactFolder) //nolint:gosec
119123

120124
By("Initializing a runtime.Scheme with all the GVK relevant for this test")
121125
scheme := initScheme()

0 commit comments

Comments
 (0)