soong: Add tests for depending on disabled module

This will check if direct deps of android.Module type is "Enabled()".
Previously, this is checked only if a module calls VisitDeps*()
functions in GenerateAndroidBuildActions().

Most modules call VisitDeps*() in GenerateAndroidBuildActions(),
but some modules don't. For example, "apex" module calls
WalkDepsBlueprint() or VisitDirectDepsBlueprint() since it
exceptionally depends on non-android.Module modules.

Therefore, when an apex module depends on disabled(enabled:false) module,
build fails with panic, which is fixed by this change.

Test: m # runs soong tests
Change-Id: I81c5c148bbd51a253d2904690eb76ae7b6df1a0f
This commit is contained in:
Jooyung Han
2019-08-23 11:18:57 +09:00
parent 577d147eb9
commit d48f3c3885
4 changed files with 125 additions and 1 deletions

View File

@@ -1902,6 +1902,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()