-
-
Notifications
You must be signed in to change notification settings - Fork 664
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove GoSource/GoLibrary from test/binary rules (#4044)
**What type of PR is this?** Starlark cleanup **What does this PR do? Why is it needed?** We don't want go_binary or go_test targets to be included in `deps` or `embed`. We have a check for it today, but we can push this into the starlark type system by ensuring they don't have these providers. **Which issues(s) does this PR fix?** Fixes # **Other notes for review** --------- Co-authored-by: Fabian Meumertzheim <[email protected]>
- Loading branch information
Showing
5 changed files
with
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
load(":common_tests.bzl", "common_test_suite") | ||
load(":context_tests.bzl", "context_test_suite") | ||
load(":provider_tests.bzl", "provider_test_suite") | ||
load(":sdk_tests.bzl", "sdk_test_suite") | ||
|
||
common_test_suite() | ||
|
||
context_test_suite() | ||
|
||
provider_test_suite() | ||
|
||
sdk_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,69 @@ | ||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("//go:def.bzl", "go_binary", "go_library", "go_test") | ||
|
||
# go_binary and go_test targets must not be used as deps/embed attributes; | ||
# their dependencies may be built in different modes, resulting in conflicts and opaque errors. | ||
def _providers_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
asserts.expect_failure(env, "does not have mandatory providers") | ||
return analysistest.end(env) | ||
|
||
providers_test = analysistest.make( | ||
_providers_test_impl, | ||
expect_failure = True, | ||
) | ||
|
||
def provider_test_suite(): | ||
go_binary( | ||
name = "go_binary", | ||
tags = ["manual"], | ||
) | ||
|
||
go_library( | ||
name = "lib_binary_deps", | ||
deps = [":go_binary"], | ||
tags = ["manual"], | ||
) | ||
|
||
providers_test( | ||
name = "go_binary_deps_test", | ||
target_under_test = ":lib_binary_deps", | ||
) | ||
|
||
go_library( | ||
name = "lib_binary_embed", | ||
embed = [":go_binary"], | ||
tags = ["manual"], | ||
) | ||
|
||
providers_test( | ||
name = "go_binary_embed_test", | ||
target_under_test = ":lib_binary_embed", | ||
) | ||
|
||
go_test( | ||
name = "go_test", | ||
tags = ["manual"], | ||
) | ||
|
||
go_library( | ||
name = "lib_test_deps", | ||
deps = [":go_test"], | ||
tags = ["manual"], | ||
) | ||
|
||
providers_test( | ||
name = "go_test_deps_test", | ||
target_under_test = ":lib_test_deps", | ||
) | ||
|
||
go_library( | ||
name = "lib_embed_test", | ||
embed = [":go_test"], | ||
tags = ["manual"], | ||
) | ||
|
||
providers_test( | ||
name = "go_test_embed_test", | ||
target_under_test = ":lib_embed_test", | ||
) |