Skip to content

Commit 4a6d8f0

Browse files
createExecutableFileInPath: create directory if it doesn't exist
1 parent f525a30 commit 4a6d8f0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mob_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,8 +2113,12 @@ func createFileInPath(t *testing.T, path, filename, content string) (pathToFile
21132113
func createExecutableFileInPath(t *testing.T, path, filename, content string) (pathToFile string) {
21142114
contentAsBytes := []byte(content)
21152115
pathToFile = path + "/" + filename
2116-
err := os.WriteFile(pathToFile, contentAsBytes, 0755)
2117-
if err != nil {
2116+
err1 := os.MkdirAll(path, 0755)
2117+
if err1 != nil {
2118+
failWithFailure(t, "creating folder "+path, "error")
2119+
}
2120+
err2 := os.WriteFile(pathToFile, contentAsBytes, 0755)
2121+
if err2 != nil {
21182122
failWithFailure(t, "creating file "+filename+" with content "+content, "error")
21192123
}
21202124
return

0 commit comments

Comments
 (0)