Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/legacy/build_constraints: Split Go asm test into own package #3652

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tests/legacy/build_constraints/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ go_library(
# Check that tags are observed.
"tag_l.go",
"tag_unknown.go",
# Check that constraints apply to assembly files.
"asm_arm64.s",
"asm_linux_amd64.s",
"asm_unknown.s",
# Check that constraints apply to cgo files.
"cgo_linux.go",
"cgo_unknown.go",
Expand Down
17 changes: 0 additions & 17 deletions tests/legacy/build_constraints/build_constraints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,6 @@ func TestTag(t *testing.T) {
check(tag, t)
}

func asm() int

func TestAsm(t *testing.T) {
got := asm()
var want int
if runtime.GOOS == "linux" {
want = 12
} else if runtime.GOARCH == "arm64" {
want = 75
} else {
want = 34
}
if got != want {
t.Errorf("got %d; want %d", got, want)
}
}

func TestCgoGo(t *testing.T) {
check(cgoGo, t)
}
Expand Down
20 changes: 20 additions & 0 deletions tests/legacy/build_constraints_go_asm/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_test(
name = "go_default_test",
size = "small",
srcs = ["build_constraints_go_asm_test.go"],
embed = [":go_default_library"],
)

go_library(
name = "go_default_library",
srcs = [
# Check that constraints apply to assembly files.
"asm_arm64.s",
"asm_linux_amd64.s",
"asm_unknown.s",
],
cgo = False,
importpath = "github.com/bazelbuild/rules_go/tests/build_constraints_go_asm",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package build_constraints_go_asm

import (
"runtime"
"testing"
)

func asm() int

func TestAsm(t *testing.T) {
got := asm()
var want int
if runtime.GOOS == "linux" {
want = 12
} else if runtime.GOARCH == "arm64" {
want = 75
} else {
want = 34
}
if got != want {
t.Errorf("got %d; want %d", got, want)
}
}