Skip to content

Commit

Permalink
Merge pull request #114 from AkihiroSuda/improve-macOSBuildTargetAvai…
Browse files Browse the repository at this point in the history
…lable-err
  • Loading branch information
Code-Hex authored Nov 22, 2022
2 parents 9de1c10 + e629e84 commit 1c3cfbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion osversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ func macOSBuildTargetAvailable(version float64) error {
target = 130000 // __MAC_13_0
}
if allowedVersion < target {
return fmt.Errorf("%w for %.1f", ErrBuildTargetOSVersion, version)
return fmt.Errorf("%w for %.1f (the binary was built with __MAC_OS_X_VERSION_MAX_ALLOWED=%d; needs recompilation)",
ErrBuildTargetOSVersion, version, allowedVersion)
}
return nil
}
12 changes: 8 additions & 4 deletions osversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,10 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
maxAllowedVersionOnce = &sync.Once{}
}()

wantErrMsgFor := func(version float64, maxAllowedVersion int) string {
return fmt.Sprintf("for %.1f (the binary was built with __MAC_OS_X_VERSION_MAX_ALLOWED=%d; needs recompilation)", version, maxAllowedVersion)
}

cases := []struct {
// version is specified only 11, 12, 12.3, 13
version float64
Expand All @@ -373,7 +377,7 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
version: 11,
maxAllowedVersion: 100000,
wantErr: true,
wantErrMsg: "for 11.0",
wantErrMsg: wantErrMsgFor(11, 100000),
},
{
version: 11,
Expand All @@ -383,7 +387,7 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
version: 12,
maxAllowedVersion: 110000,
wantErr: true,
wantErrMsg: "for 12.0",
wantErrMsg: wantErrMsgFor(12, 110000),
},
{
version: 12,
Expand All @@ -409,7 +413,7 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
version: 12.3,
maxAllowedVersion: 120000,
wantErr: true,
wantErrMsg: "for 12.3",
wantErrMsg: wantErrMsgFor(12.3, 120000),
},
{
version: 12.3,
Expand All @@ -423,7 +427,7 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
version: 13,
maxAllowedVersion: 120300,
wantErr: true,
wantErrMsg: "for 13.0",
wantErrMsg: wantErrMsgFor(13, 120300),
},
{
version: 13,
Expand Down

0 comments on commit 1c3cfbc

Please sign in to comment.