forked from bazelbuild/bazelisk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(platforms): fallback to x86_64 before bazel version 4.1.0 on App… (
bazelbuild#299) * feat(platforms): fallback to x86_64 before bazel version 4.1.0 on Apple Silicon * add test target in BUILD * fix build * rm return value err * refactor: add log, rename sem_ver to semver * refactor: add log
- Loading branch information
Showing
3 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["platforms.go"], | ||
importpath = "github.com/bazelbuild/bazelisk/platforms", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@com_github_hashicorp_go_version//:go_default_library", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "platforms_test", | ||
srcs = ["platforms_test.go"], | ||
embed = [":go_default_library"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package platforms | ||
|
||
import "testing" | ||
|
||
func TestDarwinFallback(t *testing.T) { | ||
type args struct { | ||
machineName string | ||
version string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantAlterMachineName string | ||
}{ | ||
{ | ||
name: "before 4.1.0, x86_64 do not fallback", | ||
args: args{ | ||
machineName: "x86_64", | ||
version: "4.0.1", | ||
}, | ||
wantAlterMachineName: "x86_64", | ||
}, | ||
{ | ||
name: "since 4.1.0, x86_64 do not fallback either", | ||
args: args{ | ||
machineName: "x86_64", | ||
version: "4.1.0", | ||
}, | ||
wantAlterMachineName: "x86_64", | ||
}, | ||
{ | ||
name: "before 4.1.0, arm64 not supported, fallback to x86_64 on arm64", | ||
args: args{ | ||
machineName: "arm64", | ||
version: "4.0.1", | ||
}, | ||
wantAlterMachineName: "x86_64", | ||
}, | ||
{ | ||
name: "since 4.1.0, arm64 supported, do not fallback", | ||
args: args{ | ||
machineName: "arm64", | ||
version: "4.1.0", | ||
}, | ||
wantAlterMachineName: "arm64", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
gotAlterMachineName := DarwinFallback(tt.args.machineName, tt.args.version) | ||
if gotAlterMachineName != tt.wantAlterMachineName { | ||
t.Errorf("DarwinFallback() gotAlterMachineName = %v, want %v", gotAlterMachineName, tt.wantAlterMachineName) | ||
} | ||
}) | ||
} | ||
} |