Skip to content

Commit

Permalink
Fix error when opening file in windows OS (#5717)
Browse files Browse the repository at this point in the history
* include c: at beginning of file path for windows OS

* get windows TEMP dir and use it for windows OS
  • Loading branch information
rnapoles-rh authored May 10, 2022
1 parent 0eee32d commit b7e45da
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/helper/helper_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -228,7 +229,9 @@ func CommonAfterEach(commonVar CommonVar) {
testDate := strings.Split(time.Now().Format(time.RFC3339), "T")[0]
resultsRow = prNum + "," + testDate + "," + clusterType + "," + commonVar.testFileName + "," + commonVar.testCase + "," + passedOrFailed + "," + strconv.FormatFloat(commonVar.testDuration, 'E', -1, 64) + "\n"
testResultsFile := filepath.Join("/", "tmp", "testResults.txt")

if runtime.GOOS == "windows" {
testResultsFile = filepath.Join(os.Getenv("TEMP"), "testResults.txt")
}
f, err := os.OpenFile(testResultsFile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
fmt.Println("Error when opening file: ", err)
Expand Down

0 comments on commit b7e45da

Please sign in to comment.