From 6f45cbd7a5bb6175b5fec4b0656c4a69ca4711d8 Mon Sep 17 00:00:00 2001 From: Wei Cao <1053481828@qq.com> Date: Tue, 16 Nov 2021 09:27:24 +0800 Subject: [PATCH] create resultsDir if the folder not exists --- test/conformance/image/go-runner/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/conformance/image/go-runner/main.go b/test/conformance/image/go-runner/main.go index a7e47c7c042..bf00b8c9be3 100644 --- a/test/conformance/image/go-runner/main.go +++ b/test/conformance/image/go-runner/main.go @@ -59,6 +59,13 @@ func configureAndRunWithEnv(env Getenver) error { // Print the output to stdout and a logfile which will be returned // as part of the results tarball. logFilePath := filepath.Join(resultsDir, logFileName) + // ensure the resultsDir actually exists + if _, err := os.Stat(resultsDir); os.IsNotExist(err) { + log.Printf("The resultsDir %v does not exist, will create it", resultsDir) + if mkdirErr := os.Mkdir(resultsDir, 0755); mkdirErr != nil { + return fmt.Errorf("failed to create log directory %v: %w", resultsDir, mkdirErr) + } + } logFile, err := os.Create(logFilePath) if err != nil { return fmt.Errorf("failed to create log file %v: %w", logFilePath, err)