From db462dd9878e6d412139e853e2c1224caf7452a3 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Sun, 21 Mar 2021 22:01:55 +0000 Subject: Disallow non-existent paths in sdk package Test behavior was changed a while ago so that tests by default ignore non-existent source paths (unless they explicitly check for/rely on them). Prior to that CheckSnapshot() could detect when files were missing from the snapshot but it no longer can. This change disallows non-existent source files in all the sdk tests which means that they are disallowed when processing the snapshots as they use the same preparers as were used to process the sources. This caused a test failure which has been temporarily ignored and has a TODO and bug associated with it. Bug: 183184375 Test: m nothing Change-Id: I969d8515d20ef5ae515f2b5f93d8ed4e4f8ede75 --- sdk/java_sdk_test.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'sdk/java_sdk_test.go') diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index 6f78ded35..2bc248d22 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -24,6 +24,16 @@ import ( var prepareForSdkTestWithJava = android.GroupFixturePreparers( java.PrepareForTestWithJavaBuildComponents, PrepareForTestWithSdkBuildComponents, + + // Ensure that all source paths are provided. This helps ensure that the snapshot generation is + // consistent and all files referenced from the snapshot's Android.bp file have actually been + // copied into the snapshot. + android.PrepareForTestDisallowNonExistentPaths, + + // Files needs by most of the tests. + android.MockFS{ + "Test.java": nil, + }.AddToFixture(), ) var prepareForSdkTestWithJavaSdkLibrary = android.GroupFixturePreparers( @@ -339,6 +349,7 @@ func TestSnapshotWithJavaImplLibrary(t *testing.T) { result := android.GroupFixturePreparers( prepareForSdkTestWithJava, android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil), + android.FixtureAddFile("resource.txt", nil), ).RunTestWithBp(t, ` module_exports { name: "myexports", @@ -394,7 +405,11 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl } func TestSnapshotWithJavaBootLibrary(t *testing.T) { - result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, ` + result := android.GroupFixturePreparers( + prepareForSdkTestWithJava, + android.FixtureAddFile("aidl", nil), + android.FixtureAddFile("resource.txt", nil), + ).RunTestWithBp(t, ` module_exports { name: "myexports", java_boot_libs: ["myjavalib"], @@ -1539,7 +1554,10 @@ sdk_snapshot { } func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) { - result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` + result := android.GroupFixturePreparers( + prepareForSdkTestWithJavaSdkLibrary, + android.FixtureAddFile("docs/known_doctags", nil), + ).RunTestWithBp(t, ` sdk { name: "mysdk", java_sdk_libs: ["myjavalib"], -- cgit v1.2.3-59-g8ed1b