Skip to content

Commit 4405889

Browse files
committed
update: add case for tests WSL env
1 parent 971acbd commit 4405889

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

detect_env.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ var wslContents string
146146
// https://github.com/Microsoft/WSL/issues/423#issuecomment-221627364
147147
func detectWSL() bool {
148148
if !detectedWSL {
149+
detectedWSL = true
150+
149151
b := make([]byte, 1024)
150152
// `cat /proc/version`
151153
// on mac:
@@ -164,10 +166,10 @@ func detectWSL() bool {
164166
}
165167

166168
wslContents = string(b)
169+
return strings.Contains(wslContents, "Microsoft")
167170
}
168-
detectedWSL = true
169171
}
170-
return strings.Contains(wslContents, "Microsoft")
172+
return false
171173
}
172174

173175
// refer

utils_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ func TestIsDetectColorLevel_unix(t *testing.T) {
107107
is.True(IsSupportColor())
108108
})
109109

110+
mockOsEnvByText("WSL_DISTRO_NAME=Debian", func() {
111+
is.Equal(LevelNo, DetectColorLevel())
112+
is.False(IsSupportTrueColor())
113+
is.False(IsSupport256Color())
114+
is.False(IsSupportColor())
115+
})
116+
110117
// TERM_PROGRAM=Terminus
111118
mockOsEnvByText(`
112119
TERMINUS_PLUGINS=

0 commit comments

Comments
 (0)