From 163043d6159c57b2a1896c1f6a9defff88692b12 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 12 Mar 2021 19:18:49 +0000 Subject: [PATCH] Fix TestJavaSdkLibrary... tests to work without javaMockFS() Bug: 182638834 Test: m nothing Change-Id: I140b88b3fdf2c532d266a196fee84675c518d859 --- java/androidmk_test.go | 5 ++- java/java_test.go | 70 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 62 insertions(+), 13 deletions(-) diff --git a/java/androidmk_test.go b/java/androidmk_test.go index 5bf97f9c5..347795639 100644 --- a/java/androidmk_test.go +++ b/java/androidmk_test.go @@ -135,7 +135,10 @@ func TestHostdexSpecificRequired(t *testing.T) { } func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) { - result := javaFixtureFactory.RunTestWithBp(t, ` + result := javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo-shared_library", "foo-no_shared_library"), + ).RunTestWithBp(t, ` java_sdk_library { name: "foo-shared_library", srcs: ["a.java"], diff --git a/java/java_test.go b/java/java_test.go index c5617d5a0..1c2ed2e57 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -795,7 +795,10 @@ func TestJavaSdkLibraryImport(t *testing.T) { } func TestJavaSdkLibraryImport_WithSource(t *testing.T) { - result := javaFixtureFactory.RunTestWithBp(t, ` + result := javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("sdklib"), + ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib", srcs: ["a.java"], @@ -834,7 +837,10 @@ func TestJavaSdkLibraryImport_WithSource(t *testing.T) { } func TestJavaSdkLibraryImport_Preferred(t *testing.T) { - result := javaFixtureFactory.RunTestWithBp(t, ` + result := javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("sdklib"), + ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib", srcs: ["a.java"], @@ -918,6 +924,8 @@ func TestJavaSdkLibraryEnforce(t *testing.T) { partitionToBpOption(info.toPartition)) return android.GroupFixturePreparers( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("bar"), android.FixtureWithRootAndroidBp(bpFile), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.EnforceProductPartitionInterface = proptools.BoolPtr(info.enforceProductInterface) @@ -1838,7 +1846,14 @@ func TestJavaImport(t *testing.T) { } func TestJavaSdkLibrary(t *testing.T) { - result := javaFixtureFactory.RunTestWithBp(t, ` + result := javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithPrebuiltApis(map[string][]string{ + "28": {"foo"}, + "29": {"foo"}, + "30": {"bar", "barney", "baz", "betty", "foo", "fred", "quuz", "wilma"}, + }), + ).RunTestWithBp(t, ` droiddoc_exported_dir { name: "droiddoc-templates-sdk", path: ".", @@ -1956,7 +1971,10 @@ func TestJavaSdkLibrary(t *testing.T) { } func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) { - result := javaFixtureFactory.RunTestWithBp(t, ` + result := javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("sdklib"), + ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib", srcs: ["a.java"], @@ -1989,7 +2007,10 @@ func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) { } func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) { - result := javaFixtureFactory.RunTestWithBp(t, ` + result := javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ).RunTestWithBp(t, ` java_sdk_library { name: "foo", srcs: ["a.java"], @@ -2014,7 +2035,10 @@ func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) { } func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) { - javaFixtureFactory.RunTestWithBp(t, ` + javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ).RunTestWithBp(t, ` java_sdk_library { name: "foo", srcs: ["a.java"], @@ -2033,6 +2057,10 @@ func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) { func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) { javaFixtureFactory. + Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ). ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`"foo" does not provide api scope system`)). RunTestWithBp(t, ` java_sdk_library { @@ -2052,7 +2080,10 @@ func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) { } func TestJavaSdkLibrary_Deps(t *testing.T) { - result := javaFixtureFactory.RunTestWithBp(t, ` + result := javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("sdklib"), + ).RunTestWithBp(t, ` java_sdk_library { name: "sdklib", srcs: ["a.java"], @@ -2171,7 +2202,10 @@ func TestJavaSdkLibrary_InvalidScopes(t *testing.T) { } func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) { - javaFixtureFactory.RunTestWithBp(t, ` + javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ).RunTestWithBp(t, ` java_sdk_library { name: "foo", srcs: ["a.java", "b.java"], @@ -2185,7 +2219,10 @@ func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) { } func TestJavaSdkLibrary_ModuleLib(t *testing.T) { - javaFixtureFactory.RunTestWithBp(t, ` + javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ).RunTestWithBp(t, ` java_sdk_library { name: "foo", srcs: ["a.java", "b.java"], @@ -2201,7 +2238,10 @@ func TestJavaSdkLibrary_ModuleLib(t *testing.T) { } func TestJavaSdkLibrary_SystemServer(t *testing.T) { - javaFixtureFactory.RunTestWithBp(t, ` + javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ).RunTestWithBp(t, ` java_sdk_library { name: "foo", srcs: ["a.java", "b.java"], @@ -2238,7 +2278,10 @@ func TestJavaSdkLibrary_MissingScope(t *testing.T) { } func TestJavaSdkLibrary_FallbackScope(t *testing.T) { - javaFixtureFactory.RunTestWithBp(t, ` + javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ).RunTestWithBp(t, ` java_sdk_library { name: "foo", srcs: ["a.java"], @@ -2258,7 +2301,10 @@ func TestJavaSdkLibrary_FallbackScope(t *testing.T) { } func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) { - result := javaFixtureFactory.RunTestWithBp(t, ` + result := javaFixtureFactory.Extend( + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + ).RunTestWithBp(t, ` java_sdk_library { name: "foo", srcs: ["a.java"],