-
-
Notifications
You must be signed in to change notification settings - Fork 675
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e457d5
commit f08151c
Showing
8 changed files
with
87 additions
and
28 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
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
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,25 @@ | ||
load("@io_bazel_rules_go//go/private:common.bzl", "GO_TOOLCHAIN") | ||
load(":cgo_test.bzl", "cgo_test_suite") | ||
|
||
constraint_value( | ||
name = "os_does_not_exist", | ||
constraint_setting = "@platforms//os:os", | ||
) | ||
|
||
# Make a platform we know won't have a C++ toolchain registered for it. | ||
platform( | ||
name = "platform_has_no_cc_toolchain", | ||
constraint_values = [":os_does_not_exist"], | ||
) | ||
|
||
# Make a fake Go toolchain for this platform | ||
toolchain( | ||
name = "fake_go_toolchain", | ||
target_compatible_with = [ | ||
":os_does_not_exist", | ||
], | ||
toolchain = "@go_sdk//:go_linux_amd64-impl", | ||
toolchain_type = GO_TOOLCHAIN, | ||
) | ||
|
||
cgo_test_suite() |
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,43 @@ | ||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_cross_binary") | ||
|
||
def _missing_cc_toolchain_explicit_pure_off_test(ctx): | ||
env = analysistest.begin(ctx) | ||
|
||
asserts.expect_failure(env, "has pure explicitly set to off, but no C++ toolchain could be found for its platform") | ||
|
||
return analysistest.end(env) | ||
|
||
missing_cc_toolchain_explicit_pure_off_test = analysistest.make( | ||
_missing_cc_toolchain_explicit_pure_off_test, | ||
expect_failure = True, | ||
config_settings = { | ||
"//command_line_option:extra_toolchains": str(Label("//tests/core/starlark/cgo:fake_go_toolchain")), | ||
}, | ||
) | ||
|
||
def cgo_test_suite(): | ||
go_binary( | ||
name = "cross_impure", | ||
srcs = ["main.go"], | ||
pure = "off", | ||
tags = ["manual"], | ||
) | ||
|
||
go_cross_binary( | ||
name = "go_cross_impure_cgo", | ||
platform = ":platform_has_no_cc_toolchain", | ||
target = ":cross_impure", | ||
tags = ["manual"], | ||
) | ||
|
||
missing_cc_toolchain_explicit_pure_off_test( | ||
name = "missing_cc_toolchain_explicit_pure_off_test", | ||
target_under_test = ":go_cross_impure_cgo", | ||
) | ||
|
||
"""Creates the test targets and test suite for cgo.bzl tests.""" | ||
native.test_suite( | ||
name = "cgo_tests", | ||
tests = [":missing_cc_toolchain_explicit_pure_off_test"], | ||
) |