summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2021-03-11 19:08:45 +0000
committerScott Lobdell <slobdell@google.com>2021-03-16 00:44:22 +0000
commit85534c36f81cf1557ddaa01605199bfc3a9fd76c (patch)
treef9b65ea011ac58731bc866a621f526ea8fa7e39f /java/java_test.go
parent5989878a55d2d34a1a8e5e16bb37349c4949758b (diff)
parentedc1fc38c73698499b37c40435b25ef2a5ade887 (diff)
Merge SP1A.210311.001
Change-Id: I28e9aad9ed4dd91092fd24efb136f0aac7bdb68e
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 11f6a7c21..911265532 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -25,6 +25,7 @@ import (
"strings"
"testing"
+ "android/soong/genrule"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -74,11 +75,13 @@ func testContext(config android.Config) *android.TestContext {
ctx.PreDepsMutators(python.RegisterPythonPreDepsMutators)
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
- ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(ctx.Context, OverlaySingletonFactory))
- ctx.RegisterPreSingletonType("sdk_versions", android.SingletonFactoryAdaptor(ctx.Context, sdkPreSingletonFactory))
+ ctx.RegisterPreSingletonType("overlay", OverlaySingletonFactory)
+ ctx.RegisterPreSingletonType("sdk_versions", sdkPreSingletonFactory)
android.RegisterPrebuiltMutators(ctx)
+ genrule.RegisterGenruleBuildComponents(ctx)
+
// Register module types and mutators from cc needed for JNI testing
cc.RegisterRequiredBuildComponentsForTest(ctx)
@@ -114,20 +117,26 @@ func testJavaErrorWithConfig(t *testing.T, pattern string, config android.Config
pathCtx := android.PathContextForTesting(config)
dexpreopt.SetTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx))
+ runWithErrors(t, ctx, config, pattern)
+
+ return ctx, config
+}
+
+func runWithErrors(t *testing.T, ctx *android.TestContext, config android.Config, pattern string) {
ctx.Register()
_, errs := ctx.ParseBlueprintsFiles("Android.bp")
if len(errs) > 0 {
android.FailIfNoMatchingErrors(t, pattern, errs)
- return ctx, config
+ return
}
_, errs = ctx.PrepareBuildActions(config)
if len(errs) > 0 {
android.FailIfNoMatchingErrors(t, pattern, errs)
- return ctx, config
+ return
}
t.Fatalf("missing expected error %q (0 errors are returned)", pattern)
- return ctx, config
+ return
}
func testJavaWithFS(t *testing.T, bp string, fs map[string][]byte) (*android.TestContext, android.Config) {