-
-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GoPackagesDriver: Reducing duplicate information passed by go_pkg_inf…
…o_aspect (#3111) * avoid writing package json for go_test dependencies
- Loading branch information
Showing
10 changed files
with
128 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
load(":go_pkg_info_aspect_test.bzl", "package_driver_suite") | ||
|
||
package_driver_suite( | ||
name = "package_driver_test" | ||
) |
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,9 @@ | ||
load("//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["a.go"], | ||
importpath = "example.com/a", | ||
visibility = ["//tests/core/starlark/packagedriver:__subpackages__"], | ||
) | ||
|
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,5 @@ | ||
package a | ||
|
||
func A() { | ||
return | ||
} |
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,8 @@ | ||
load("//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["b.go"], | ||
importpath = "example.com/b", | ||
visibility = ["//tests/core/starlark/packagedriver:__subpackages__"], | ||
) |
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,5 @@ | ||
package b | ||
|
||
func B() { | ||
return | ||
} |
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("//go:def.bzl", "go_library", "go_test") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["c.go"], | ||
importpath = "example.com/c", | ||
visibility = ["//tests/core/starlark/packagedriver:__subpackages__"], | ||
deps = [ | ||
"//tests/core/starlark/packagedriver/fixtures/a:go_default_library", | ||
"//tests/core/starlark/packagedriver/fixtures/b:go_default_library", | ||
], | ||
) | ||
|
||
go_test( | ||
name = "go_default_test", | ||
srcs = ["c_test.go"], | ||
embed = [":go_default_library"], | ||
tags = ["manual"], | ||
visibility = ["//tests/core/starlark/packagedriver:__subpackages__"], | ||
) |
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,11 @@ | ||
package c | ||
|
||
import ( | ||
"example.com/a" | ||
"example.com/b" | ||
) | ||
|
||
func C() { | ||
a.A() | ||
b.B() | ||
} |
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,9 @@ | ||
package c | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestC(t *testing.T) { | ||
C() | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/core/starlark/packagedriver/go_pkg_info_aspect_test.bzl
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,33 @@ | ||
load("@bazel_skylib//lib:unittest.bzl", "asserts", "analysistest") | ||
load("//go/tools/gopackagesdriver:aspect.bzl", "go_pkg_info_aspect") | ||
|
||
|
||
def _package_driver_pkg_json_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
|
||
target_under_test = analysistest.target_under_test(env) | ||
json_files = [f.basename for f in target_under_test[OutputGroupInfo].go_pkg_driver_json_file.to_list()] | ||
asserts.true(env, "go_default_test.pkg.json" in json_files, "{} does not contain go_default_test.pkg.json".format(json_files)) | ||
|
||
return analysistest.end(env) | ||
|
||
package_driver_pkg_json_test = analysistest.make( | ||
_package_driver_pkg_json_test_impl, | ||
extra_target_under_test_aspects = [go_pkg_info_aspect], | ||
) | ||
|
||
def _test_package_driver(): | ||
package_driver_pkg_json_test( | ||
name = "package_driver_should_return_pkg_json_for_go_test", | ||
target_under_test = "//tests/core/starlark/packagedriver/fixtures/c:go_default_test", | ||
) | ||
|
||
def package_driver_suite(name): | ||
_test_package_driver() | ||
|
||
native.test_suite( | ||
name = name, | ||
tests = [ | ||
":package_driver_should_return_pkg_json_for_go_test", | ||
], | ||
) |