summaryrefslogtreecommitdiff
path: root/java/testing.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2020-07-09 17:32:57 +0100
committer Paul Duffin <paulduffin@google.com> 2020-07-09 17:51:06 +0100
commitcee7e66b07cdea5d37fbdd94bb1a34cc8caa448f (patch)
treea426527fda0c17f2fb52ae212f805ca8fae40857 /java/testing.go
parent2c79c871d9a7e521a77a9fd0466eb932f5c92cc1 (diff)
Ensure that sdk/module_exports depends on source members
Previously, preferring a prebuilt of an sdk/module_exports's member would cause the sdk/module_exports to depend on the prebuilt instead of the source and cause problems with the build. This chance prevents the dependency from an sdk/module_exports to its members from being replaced with prebuilts. Bug: 160785918 Test: m nothing Change-Id: Iee4bcd438c11929e30fb5766701b05a0e89956d9
Diffstat (limited to 'java/testing.go')
-rw-r--r--java/testing.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/java/testing.go b/java/testing.go
index f5688e627..94f054e67 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -16,9 +16,13 @@ package java
import (
"fmt"
+ "reflect"
+ "sort"
+ "testing"
"android/soong/android"
"android/soong/cc"
+ "github.com/google/blueprint"
)
func TestConfig(buildDir string, env map[string]string, bp string, fs map[string][]byte) android.Config {
@@ -216,3 +220,17 @@ func GatherRequiredDepsForTest() string {
return bp
}
+
+func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, variant string, expected []string) {
+ t.Helper()
+ module := ctx.ModuleForTests(name, variant).Module()
+ deps := []string{}
+ ctx.VisitDirectDeps(module, func(m blueprint.Module) {
+ deps = append(deps, m.Name())
+ })
+ sort.Strings(deps)
+
+ if actual := deps; !reflect.DeepEqual(expected, actual) {
+ t.Errorf("expected %#q, found %#q", expected, actual)
+ }
+}