Skip to content

Commit e629e84

Browse files
committed
mcaOSBuildTargetAvailable(): include __MAC_OS_X_VERSION_MAX_ALLOWED in error
Should be helpful for analyzing issues like lima-vm/lima issue 1182 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
1 parent 9de1c10 commit e629e84

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

osversion.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ func macOSBuildTargetAvailable(version float64) error {
105105
target = 130000 // __MAC_13_0
106106
}
107107
if allowedVersion < target {
108-
return fmt.Errorf("%w for %.1f", ErrBuildTargetOSVersion, version)
108+
return fmt.Errorf("%w for %.1f (the binary was built with __MAC_OS_X_VERSION_MAX_ALLOWED=%d; needs recompilation)",
109+
ErrBuildTargetOSVersion, version, allowedVersion)
109110
}
110111
return nil
111112
}

osversion_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,10 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
356356
maxAllowedVersionOnce = &sync.Once{}
357357
}()
358358

359+
wantErrMsgFor := func(version float64, maxAllowedVersion int) string {
360+
return fmt.Sprintf("for %.1f (the binary was built with __MAC_OS_X_VERSION_MAX_ALLOWED=%d; needs recompilation)", version, maxAllowedVersion)
361+
}
362+
359363
cases := []struct {
360364
// version is specified only 11, 12, 12.3, 13
361365
version float64
@@ -373,7 +377,7 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
373377
version: 11,
374378
maxAllowedVersion: 100000,
375379
wantErr: true,
376-
wantErrMsg: "for 11.0",
380+
wantErrMsg: wantErrMsgFor(11, 100000),
377381
},
378382
{
379383
version: 11,
@@ -383,7 +387,7 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
383387
version: 12,
384388
maxAllowedVersion: 110000,
385389
wantErr: true,
386-
wantErrMsg: "for 12.0",
390+
wantErrMsg: wantErrMsgFor(12, 110000),
387391
},
388392
{
389393
version: 12,
@@ -409,7 +413,7 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
409413
version: 12.3,
410414
maxAllowedVersion: 120000,
411415
wantErr: true,
412-
wantErrMsg: "for 12.3",
416+
wantErrMsg: wantErrMsgFor(12.3, 120000),
413417
},
414418
{
415419
version: 12.3,
@@ -423,7 +427,7 @@ func Test_macOSBuildTargetAvailable(t *testing.T) {
423427
version: 13,
424428
maxAllowedVersion: 120300,
425429
wantErr: true,
426-
wantErrMsg: "for 13.0",
430+
wantErrMsg: wantErrMsgFor(13, 120300),
427431
},
428432
{
429433
version: 13,

0 commit comments

Comments
 (0)