diff --git a/src/constants_unix.go b/src/constants_unix.go new file mode 100644 index 00000000..ab291ea6 --- /dev/null +++ b/src/constants_unix.go @@ -0,0 +1,7 @@ +// +build !windows + +package main + +const ( + dotnetExitCode = 142 +) diff --git a/src/constants_windows64.go b/src/constants_windows64.go new file mode 100644 index 00000000..ba451e1f --- /dev/null +++ b/src/constants_windows64.go @@ -0,0 +1,8 @@ +// +build windows +// +build amd64 + +package main + +const ( + dotnetExitCode = int(0x80008091) +) diff --git a/src/constrants_windows386.go b/src/constrants_windows386.go new file mode 100644 index 00000000..04c8c680 --- /dev/null +++ b/src/constrants_windows386.go @@ -0,0 +1,8 @@ +// +build windows +// +build 386 + +package main + +const ( + dotnetExitCode = -2147450735 +) diff --git a/src/segment_dotnet.go b/src/segment_dotnet.go index ac8d3891..55a6ad3f 100644 --- a/src/segment_dotnet.go +++ b/src/segment_dotnet.go @@ -8,19 +8,13 @@ const ( // UnsupportedDotnetVersionIcon is displayed when the dotnet version in // the current folder isn't supported by the installed dotnet SDK set. UnsupportedDotnetVersionIcon Property = "unsupported_version_icon" - - dotnetExitCodeUnix = 145 - dotnetExitCodeWindows = -2147450735 ) func (d *dotnet) string() string { version := d.language.string() - // Exit codes 145 and 0x80008091 are special indicators that dotnet - // ran, but the current project config settings specify - // use of an SDK that isn't installed. exitCode := d.language.exitCode - if exitCode == dotnetExitCodeWindows || exitCode == dotnetExitCodeUnix { + if exitCode == dotnetExitCode { return d.language.props.getString(UnsupportedDotnetVersionIcon, "\uf071 ") } diff --git a/src/segment_dotnet_test.go b/src/segment_dotnet_test.go index e13140f6..e9985707 100644 --- a/src/segment_dotnet_test.go +++ b/src/segment_dotnet_test.go @@ -71,24 +71,10 @@ func TestDotnetVersionDisplayed(t *testing.T) { } func TestDotnetVersionUnsupported(t *testing.T) { - expected := "x" args := &dotnetArgs{ enabled: true, displayVersion: true, - exitCode: dotnetExitCodeUnix, - unsupportedIcon: expected, - } - dotnet := bootStrapDotnetTest(args) - assert.True(t, dotnet.enabled()) - assert.Equal(t, expected, dotnet.string()) -} - -func TestDotnetVersionUnsupportedWindows(t *testing.T) { - expected := "x" - args := &dotnetArgs{ - enabled: true, - displayVersion: true, - exitCode: dotnetExitCodeWindows, + exitCode: dotnetExitCode, unsupportedIcon: expected, } dotnet := bootStrapDotnetTest(args)