Fix TLS directory path on WSL

This commit is contained in:
Riccardo Biraghi
2018-04-11 09:25:08 +01:00
parent d56fce65c2
commit 9851743ae2
3 changed files with 24 additions and 12 deletions

View File

@@ -85,27 +85,29 @@ func coverageBind(t *testing.T) string {
// isWSL return whether we are running in the Windows Subsystem for Linux
func isWSL(t *testing.T) bool {
if runtime.GOOS == "linux" {
uname, err := exec.Command("uname", "-r").Output()
if (err != nil) {
t.Fatal(err)
}
return strings.Contains(string(uname), "Microsoft")
} else {
return false
}
}
// getWindowsRoot get the path of the root directory on Windows, in UNIX or OS-specific style
func getWindowsRoot(unixStylePath bool) string {
if unixStylePath {
return "/mnt/c/"
} else {
return "C:/"
}
}
// getTempDir get the path of the tmp directory, in UNIX or OS-specific style
func getTempDir(t *testing.T, unixStylePath bool) string {
if isWSL(t) {
if unixStylePath {
return "/mnt/c/Temp/"
} else {
return "C:/Temp/"
}
return getWindowsRoot(unixStylePath) + "Temp/"
} else {
return "/tmp/"
}