fix(dotnet): correct exit code for different OS architectures

closes #819
This commit is contained in:
Jan De Dobbeleer 2021-06-23 22:19:43 +02:00 committed by Jan De Dobbeleer
parent 3fd70ce716
commit db1f6bb751
5 changed files with 25 additions and 22 deletions

7
src/constants_unix.go Normal file
View file

@ -0,0 +1,7 @@
// +build !windows
package main
const (
dotnetExitCode = 142
)

View file

@ -0,0 +1,8 @@
// +build windows
// +build amd64
package main
const (
dotnetExitCode = int(0x80008091)
)

View file

@ -0,0 +1,8 @@
// +build windows
// +build 386
package main
const (
dotnetExitCode = -2147450735
)

View file

@ -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 ")
}

View file

@ -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)