-
-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/legacy/build_constraints: Split Go asm test into own package (#…
…3652) The native "go build" tool compiles assembly in a Cgo package with the C compiler, and compiles assembly in a pure Go package with the Go assembler. The build_constraints test previously mixed Go assembler files with Cgo files. This caused the native go test to fail with: package using cgo has Go assembly file asm_linux_amd64.s Splitting this into two separate packages fixes this. This problem was reported in: #2006 This will fix failing tests in my attempt to fix that issue: #3648
- Loading branch information
Showing
7 changed files
with
43 additions
and
21 deletions.
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
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,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", | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
tests/legacy/build_constraints_go_asm/build_constraints_go_asm_test.go
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,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) | ||
} | ||
} |