Skip to content

Commit

Permalink
update: add case for tests WSL env
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 10, 2021
1 parent 971acbd commit 4405889
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions detect_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ var wslContents string
// https://github.com/Microsoft/WSL/issues/423#issuecomment-221627364
func detectWSL() bool {
if !detectedWSL {
detectedWSL = true

b := make([]byte, 1024)
// `cat /proc/version`
// on mac:
Expand All @@ -164,10 +166,10 @@ func detectWSL() bool {
}

wslContents = string(b)
return strings.Contains(wslContents, "Microsoft")
}
detectedWSL = true
}
return strings.Contains(wslContents, "Microsoft")
return false
}

// refer
Expand Down
7 changes: 7 additions & 0 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ func TestIsDetectColorLevel_unix(t *testing.T) {
is.True(IsSupportColor())
})

mockOsEnvByText("WSL_DISTRO_NAME=Debian", func() {
is.Equal(LevelNo, DetectColorLevel())
is.False(IsSupportTrueColor())
is.False(IsSupport256Color())
is.False(IsSupportColor())
})

// TERM_PROGRAM=Terminus
mockOsEnvByText(`
TERMINUS_PLUGINS=
Expand Down

0 comments on commit 4405889

Please sign in to comment.