Merge "soong: Add tests for depending on disabled module"
This commit is contained in:
commit
a9caf47ea2
|
@ -1038,6 +1038,13 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||
}
|
||||
|
||||
if m.Enabled() {
|
||||
// ensure all direct android.Module deps are enabled
|
||||
ctx.VisitDirectDepsBlueprint(func(bm blueprint.Module) {
|
||||
if _, ok := bm.(Module); ok {
|
||||
ctx.validateAndroidModule(bm, ctx.baseModuleContext.strictVisitDeps)
|
||||
}
|
||||
})
|
||||
|
||||
notice := proptools.StringDefault(m.commonProperties.Notice, "NOTICE")
|
||||
if module := SrcIsModule(notice); module != "" {
|
||||
m.noticeFile = ctx.ExpandOptionalSource(¬ice, "notice")
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
|
||||
package android
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSrcIsModule(t *testing.T) {
|
||||
type args struct {
|
||||
|
@ -139,3 +141,55 @@ func TestSrcIsModuleWithTag(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
type depsModule struct {
|
||||
ModuleBase
|
||||
props struct {
|
||||
Deps []string
|
||||
}
|
||||
}
|
||||
|
||||
func (m *depsModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
}
|
||||
|
||||
func (m *depsModule) DepsMutator(ctx BottomUpMutatorContext) {
|
||||
ctx.AddDependency(ctx.Module(), nil, m.props.Deps...)
|
||||
}
|
||||
|
||||
func depsModuleFactory() Module {
|
||||
m := &depsModule{}
|
||||
m.AddProperties(&m.props)
|
||||
InitAndroidModule(m)
|
||||
return m
|
||||
}
|
||||
|
||||
func TestErrorDependsOnDisabledModule(t *testing.T) {
|
||||
ctx := NewTestContext()
|
||||
ctx.RegisterModuleType("deps", ModuleFactoryAdaptor(depsModuleFactory))
|
||||
|
||||
bp := `
|
||||
deps {
|
||||
name: "foo",
|
||||
deps: ["bar"],
|
||||
}
|
||||
deps {
|
||||
name: "bar",
|
||||
enabled: false,
|
||||
}
|
||||
`
|
||||
|
||||
mockFS := map[string][]byte{
|
||||
"Android.bp": []byte(bp),
|
||||
}
|
||||
|
||||
ctx.MockFileSystem(mockFS)
|
||||
|
||||
ctx.Register()
|
||||
|
||||
config := TestConfig(buildDir, nil)
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
FailIfNoMatchingErrors(t, `module "foo": depends on disabled module "bar"`, errs)
|
||||
}
|
||||
|
|
|
@ -1932,6 +1932,51 @@ func TestApexUsesFailsIfUseNoApex(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
func TestErrorsIfDepsAreNotEnabled(t *testing.T) {
|
||||
testApexError(t, `module "myapex" .* depends on disabled module "libfoo"`, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
native_shared_libs: ["libfoo"],
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
public_key: "testkey.avbpubkey",
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libfoo",
|
||||
stl: "none",
|
||||
system_shared_libs: [],
|
||||
enabled: false,
|
||||
}
|
||||
`)
|
||||
testApexError(t, `module "myapex" .* depends on disabled module "myjar"`, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
java_libs: ["myjar"],
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
public_key: "testkey.avbpubkey",
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "myjar",
|
||||
srcs: ["foo/bar/MyClass.java"],
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
compile_dex: true,
|
||||
enabled: false,
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
run := func() int {
|
||||
setUp()
|
||||
|
|
|
@ -2264,6 +2264,24 @@ func TestStaticDepsOrderWithStubs(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestErrorsIfAModuleDependsOnDisabled(t *testing.T) {
|
||||
testCcError(t, `module "libA" .* depends on disabled module "libB"`, `
|
||||
cc_library {
|
||||
name: "libA",
|
||||
srcs: ["foo.c"],
|
||||
shared_libs: ["libB"],
|
||||
stl: "none",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libB",
|
||||
srcs: ["foo.c"],
|
||||
enabled: false,
|
||||
stl: "none",
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
// Simple smoke test for the cc_fuzz target that ensures the rule compiles
|
||||
// correctly.
|
||||
func TestFuzzTarget(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue