gen_module visibility tests. am: 0507921dcf
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2098695 Change-Id: I1f07372fd8f6ce9aa37b4a04b73af516b9d00455 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -83,6 +83,8 @@ var PrepareForTestWithLicenses = GroupFixturePreparers(
|
||||
FixtureRegisterWithContext(registerLicenseMutators),
|
||||
)
|
||||
|
||||
var PrepareForTestWithGenNotice = FixtureRegisterWithContext(RegisterGenNoticeBuildComponents)
|
||||
|
||||
func registerLicenseMutators(ctx RegistrationContext) {
|
||||
ctx.PreArchMutators(RegisterLicensesPackageMapper)
|
||||
ctx.PreArchMutators(RegisterLicensesPropertyGatherer)
|
||||
|
@@ -139,16 +139,31 @@ var visibilityTests = []struct {
|
||||
mock_library {
|
||||
name: "libsamepackage",
|
||||
deps: ["libexample"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libnested",
|
||||
deps: ["libexample"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libother",
|
||||
deps: ["libexample"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
@@ -185,6 +200,44 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that //visibility:private allows the module to be referenced from the current
|
||||
// directory only.
|
||||
name: "//visibility:private (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
|
||||
mock_library {
|
||||
name: "libsamepackage",
|
||||
deps: ["libexample"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "nested-notice" references "//top:libexample" which is not visible to this` +
|
||||
` module\nYou may need to add "//top/nested" to its visibility`,
|
||||
`module "other-notice" references "//top:libexample" which is not visible to this module\n` +
|
||||
`You may need to add "//other" to its visibility`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that :__pkg__ allows the module to be referenced from the current directory only.
|
||||
name: ":__pkg__",
|
||||
@@ -217,6 +270,36 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that :__pkg__ allows the module to be referenced from the current directory only.
|
||||
name: ":__pkg__ (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: [":__pkg__"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "nested-notice" references "//top:libexample" which is not visible to this module`,
|
||||
`module "other-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that //top/nested allows the module to be referenced from the current directory and
|
||||
// the top/nested directory only, not a subdirectory of top/nested and not peak directory.
|
||||
@@ -255,6 +338,42 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that //top/nested allows the module to be referenced from the current directory and
|
||||
// the top/nested directory only, not a subdirectory of top/nested and not peak directory.
|
||||
name: "//top/nested (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//top/nested"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/again/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nestedagain-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"peak/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "other-notice" references "//top:libexample" which is not visible to this module`,
|
||||
`module "nestedagain-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that :__subpackages__ allows the module to be referenced from the current directory
|
||||
// and sub directories but nowhere else.
|
||||
@@ -286,6 +405,36 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that :__subpackages__ allows the module to be referenced from the current directory
|
||||
// and sub directories but nowhere else.
|
||||
name: ":__subpackages__ (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: [":__subpackages__"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"peak/other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "other-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that //top/nested:__subpackages__ allows the module to be referenced from the current
|
||||
// directory and sub directories but nowhere else.
|
||||
@@ -317,6 +466,36 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that //top/nested:__subpackages__ allows the module to be referenced from the current
|
||||
// directory and sub directories but nowhere else.
|
||||
name: "//top/nested:__subpackages__ (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//top/nested:__subpackages__", "//other"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "other-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that ["//top/nested", "//peak:__subpackages"] allows the module to be referenced from
|
||||
// the current directory, top/nested and peak and all its subpackages.
|
||||
@@ -344,6 +523,33 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that ["//top/nested", "//peak:__subpackages"] allows the module to be referenced from
|
||||
// the current directory, top/nested and peak and all its subpackages.
|
||||
name: `["//top/nested", "//peak:__subpackages__ (notices)"]`,
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//top/nested", "//peak:__subpackages__"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"peak/other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
// Verify that //vendor... cannot be used outside vendor apart from //vendor:__subpackages__
|
||||
name: `//vendor`,
|
||||
@@ -417,6 +623,45 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// Check that visibility is the union of the defaults modules.
|
||||
name: "defaults union, basic (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults",
|
||||
visibility: ["//other"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//top/nested"],
|
||||
defaults: ["libexample_defaults"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outsider-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "defaults union, multiple defaults",
|
||||
fs: MockFS{
|
||||
@@ -458,6 +703,47 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "defaults union, multiple defaults (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults_1",
|
||||
visibility: ["//other"],
|
||||
}
|
||||
mock_defaults {
|
||||
name: "libexample_defaults_2",
|
||||
visibility: ["//top/nested"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
defaults: ["libexample_defaults_1", "libexample_defaults_2"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outsider-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:public mixed with other in defaults",
|
||||
fs: MockFS{
|
||||
@@ -499,6 +785,29 @@ var visibilityTests = []struct {
|
||||
qualifiedModuleName{pkg: "top", name: "libexample"}: {"//visibility:public"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:public overriding defaults (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults",
|
||||
visibility: ["//namespace"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//visibility:public"],
|
||||
defaults: ["libexample_defaults"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
effectiveVisibility: map[qualifiedModuleName][]string{
|
||||
qualifiedModuleName{pkg: "top", name: "libexample"}: {"//visibility:public"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:public mixed with other from different defaults 1",
|
||||
fs: MockFS{
|
||||
@@ -522,6 +831,34 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:public mixed with other from different defaults 1",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults_1",
|
||||
visibility: ["//namespace"],
|
||||
}
|
||||
mock_defaults {
|
||||
name: "libexample_defaults_2",
|
||||
visibility: ["//visibility:public"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
defaults: ["libexample_defaults_1", "libexample_defaults_2"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:public mixed with other from different defaults 2",
|
||||
fs: MockFS{
|
||||
@@ -545,6 +882,29 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:public mixed with other from different defaults 2 (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults_1",
|
||||
visibility: ["//visibility:public"],
|
||||
}
|
||||
mock_defaults {
|
||||
name: "libexample_defaults_2",
|
||||
visibility: ["//namespace"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
defaults: ["libexample_defaults_1", "libexample_defaults_2"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:private in defaults",
|
||||
fs: MockFS{
|
||||
@@ -579,6 +939,39 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:private in defaults (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
defaults: ["libexample_defaults"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "libexample-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "nested-notice" references "//top:libexample" which is not visible to this module`,
|
||||
`module "other-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:private mixed with other in defaults",
|
||||
fs: MockFS{
|
||||
@@ -705,6 +1098,27 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override discards //visibility:private (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
// Make this visibility to //other but not //visibility:private
|
||||
visibility: ["//visibility:override", "//other"],
|
||||
defaults: ["libexample_defaults"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override discards //visibility:public",
|
||||
fs: MockFS{
|
||||
@@ -734,6 +1148,35 @@ var visibilityTests = []struct {
|
||||
`module "libnamespace" variant "android_common": depends on //top:libexample which is not visible to this module\nYou may need to add "//namespace" to its visibility`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override discards //visibility:public (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults",
|
||||
visibility: ["//visibility:public"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
// Make this visibility to //other but not //visibility:public
|
||||
visibility: ["//visibility:override", "//other"],
|
||||
defaults: ["libexample_defaults"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"namespace/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "namespace-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "namespace-notice" references "//top:libexample" which is not visible to this module\nYou may need to add "//namespace" to its visibility`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override discards defaults supplied rules",
|
||||
fs: MockFS{
|
||||
@@ -763,6 +1206,35 @@ var visibilityTests = []struct {
|
||||
`module "libnamespace" variant "android_common": depends on //top:libexample which is not visible to this module\nYou may need to add "//namespace" to its visibility`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override discards defaults supplied rules (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults",
|
||||
visibility: ["//namespace"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
// Make this visibility to //other but not //namespace
|
||||
visibility: ["//visibility:override", "//other"],
|
||||
defaults: ["libexample_defaults"],
|
||||
}`),
|
||||
"other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"namespace/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "namespace-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "namespace-notice" references "//top:libexample" which is not visible to this module\nYou may need to add "//namespace" to its visibility`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override can override //visibility:public with //visibility:private",
|
||||
fs: MockFS{
|
||||
@@ -786,6 +1258,29 @@ var visibilityTests = []struct {
|
||||
`module "libnamespace" variant "android_common": depends on //top:libexample which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override can override //visibility:public with //visibility:private (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults",
|
||||
visibility: ["//visibility:public"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//visibility:override", "//visibility:private"],
|
||||
defaults: ["libexample_defaults"],
|
||||
}`),
|
||||
"namespace/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "namespace-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "namespace-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override can override //visibility:private with //visibility:public",
|
||||
fs: MockFS{
|
||||
@@ -806,6 +1301,26 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:override can override //visibility:private with //visibility:public (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//visibility:override", "//visibility:public"],
|
||||
defaults: ["libexample_defaults"],
|
||||
}`),
|
||||
"namespace/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "namespace-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:private mixed with itself",
|
||||
fs: MockFS{
|
||||
@@ -834,6 +1349,33 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "//visibility:private mixed with itself (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_defaults {
|
||||
name: "libexample_defaults_1",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
mock_defaults {
|
||||
name: "libexample_defaults_2",
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//visibility:private"],
|
||||
defaults: ["libexample_defaults_1", "libexample_defaults_2"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outsider-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
|
||||
// Defaults module's defaults_visibility tests
|
||||
{
|
||||
@@ -902,6 +1444,28 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
// This test relies on the default visibility being legacy_public.
|
||||
name: "package default_visibility property used when no visibility specified (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
package {
|
||||
default_visibility: ["//visibility:private"],
|
||||
}
|
||||
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outsider-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility public does not override visibility private",
|
||||
fs: MockFS{
|
||||
@@ -925,6 +1489,28 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility public does not override visibility private (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
package {
|
||||
default_visibility: ["//visibility:public"],
|
||||
}
|
||||
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//visibility:private"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outsider-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility private does not override visibility public",
|
||||
fs: MockFS{
|
||||
@@ -944,6 +1530,25 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility private does not override visibility public (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
package {
|
||||
default_visibility: ["//visibility:private"],
|
||||
}
|
||||
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: ["//visibility:public"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility :__subpackages__",
|
||||
fs: MockFS{
|
||||
@@ -971,6 +1576,32 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility :__subpackages__ (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
package {
|
||||
default_visibility: [":__subpackages__"],
|
||||
}
|
||||
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outsider-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility inherited to subpackages",
|
||||
fs: MockFS{
|
||||
@@ -999,6 +1630,38 @@ var visibilityTests = []struct {
|
||||
` visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility inherited to subpackages (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
package {
|
||||
default_visibility: ["//outsider"],
|
||||
}
|
||||
|
||||
mock_library {
|
||||
name: "libexample",
|
||||
visibility: [":__subpackages__"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libnested",
|
||||
deps: ["libexample"],
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libexample"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libexample", "libnested"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outsider-notice" references "//top:libexample" which is not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility inherited to subpackages",
|
||||
fs: MockFS{
|
||||
@@ -1029,6 +1692,41 @@ var visibilityTests = []struct {
|
||||
` not visible to this module`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "package default_visibility inherited to subpackages (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
package {
|
||||
default_visibility: ["//visibility:private"],
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
package {
|
||||
default_visibility: ["//outsider"],
|
||||
}
|
||||
|
||||
mock_library {
|
||||
name: "libnested",
|
||||
}`),
|
||||
"top/other/Android.bp": []byte(`
|
||||
mock_library {
|
||||
name: "libother",
|
||||
}
|
||||
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libother"],
|
||||
}`),
|
||||
"outsider/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "outsider-notice",
|
||||
for: ["libother", "libnested"],
|
||||
}`),
|
||||
},
|
||||
expectedErrors: []string{
|
||||
`module "outsider-notice" references "//top/other:libother" which is not visible to this` +
|
||||
` module\nYou may need to add "//outsider" to its visibility`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "verify that prebuilt dependencies are ignored for visibility reasons (not preferred)",
|
||||
fs: MockFS{
|
||||
@@ -1051,6 +1749,28 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "verify that prebuilt dependencies are ignored for visibility reasons (not preferred) (notices)",
|
||||
fs: MockFS{
|
||||
"prebuilts/Android.bp": []byte(`
|
||||
prebuilt {
|
||||
name: "module",
|
||||
visibility: ["//top/other"],
|
||||
}`),
|
||||
"top/sources/source_file": nil,
|
||||
"top/sources/Android.bp": []byte(`
|
||||
source {
|
||||
name: "module",
|
||||
visibility: ["//top/other"],
|
||||
}`),
|
||||
"top/other/source_file": nil,
|
||||
"top/other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["module"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "verify that prebuilt dependencies are ignored for visibility reasons (preferred)",
|
||||
fs: MockFS{
|
||||
@@ -1074,6 +1794,29 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "verify that prebuilt dependencies are ignored for visibility reasons (preferred) (notices)",
|
||||
fs: MockFS{
|
||||
"prebuilts/Android.bp": []byte(`
|
||||
prebuilt {
|
||||
name: "module",
|
||||
visibility: ["//top/other"],
|
||||
prefer: true,
|
||||
}`),
|
||||
"top/sources/source_file": nil,
|
||||
"top/sources/Android.bp": []byte(`
|
||||
source {
|
||||
name: "module",
|
||||
visibility: ["//top/other"],
|
||||
}`),
|
||||
"top/other/source_file": nil,
|
||||
"top/other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["module"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ensure visibility properties are checked for correctness",
|
||||
fs: MockFS{
|
||||
@@ -1137,6 +1880,30 @@ var visibilityTests = []struct {
|
||||
}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "automatic visibility inheritance enabled (notices)",
|
||||
fs: MockFS{
|
||||
"top/Android.bp": []byte(`
|
||||
mock_parent {
|
||||
name: "parent",
|
||||
visibility: ["//top/nested"],
|
||||
child: {
|
||||
name: "libchild",
|
||||
visibility: ["//top/other"],
|
||||
},
|
||||
}`),
|
||||
"top/nested/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "nested-notice",
|
||||
for: ["libchild"],
|
||||
}`),
|
||||
"top/other/Android.bp": []byte(`
|
||||
gen_notice {
|
||||
name: "other-notice",
|
||||
for: ["libchild"],
|
||||
}`),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestVisibility(t *testing.T) {
|
||||
@@ -1147,6 +1914,7 @@ func TestVisibility(t *testing.T) {
|
||||
// registration order.
|
||||
PrepareForTestWithArchMutator,
|
||||
PrepareForTestWithDefaults,
|
||||
PrepareForTestWithGenNotice,
|
||||
PrepareForTestWithOverrides,
|
||||
PrepareForTestWithPackageModule,
|
||||
PrepareForTestWithPrebuilts,
|
||||
|
Reference in New Issue
Block a user