Paul Duffin | 8150da6 | 2019-12-16 17:21:27 +0000 | [diff] [blame] | 1 | // Copyright 2019 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package sdk |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | ) |
| 20 | |
| 21 | // Ensure that module_exports generates a module_exports_snapshot module. |
| 22 | func TestModuleExportsSnapshot(t *testing.T) { |
| 23 | packageBp := ` |
| 24 | module_exports { |
| 25 | name: "myexports", |
| 26 | java_libs: [ |
| 27 | "myjavalib", |
| 28 | ], |
| 29 | } |
| 30 | |
| 31 | java_library { |
| 32 | name: "myjavalib", |
| 33 | srcs: ["Test.java"], |
| 34 | system_modules: "none", |
| 35 | sdk_version: "none", |
| 36 | } |
| 37 | ` |
| 38 | |
| 39 | result := testSdkWithFs(t, ``, |
| 40 | map[string][]byte{ |
| 41 | "package/Test.java": nil, |
| 42 | "package/Android.bp": []byte(packageBp), |
| 43 | }) |
| 44 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 45 | CheckSnapshot(t, result, "myexports", "package", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 46 | checkUnversionedAndroidBpContents(` |
| 47 | // This is auto-generated. DO NOT EDIT. |
| 48 | |
| 49 | java_import { |
| 50 | name: "myjavalib", |
| 51 | prefer: false, |
| 52 | visibility: ["//visibility:public"], |
| 53 | apex_available: ["//apex_available:platform"], |
| 54 | jars: ["java/myjavalib.jar"], |
| 55 | } |
| 56 | `), |
| 57 | checkVersionedAndroidBpContents(` |
Paul Duffin | 8150da6 | 2019-12-16 17:21:27 +0000 | [diff] [blame] | 58 | // This is auto-generated. DO NOT EDIT. |
| 59 | |
| 60 | java_import { |
| 61 | name: "myexports_myjavalib@current", |
| 62 | sdk_member_name: "myjavalib", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 63 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 64 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 8150da6 | 2019-12-16 17:21:27 +0000 | [diff] [blame] | 65 | jars: ["java/myjavalib.jar"], |
| 66 | } |
| 67 | |
Paul Duffin | 8150da6 | 2019-12-16 17:21:27 +0000 | [diff] [blame] | 68 | module_exports_snapshot { |
| 69 | name: "myexports@current", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 70 | visibility: ["//visibility:public"], |
Paul Duffin | 8150da6 | 2019-12-16 17:21:27 +0000 | [diff] [blame] | 71 | java_libs: ["myexports_myjavalib@current"], |
| 72 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 73 | `), |
| 74 | ) |
Paul Duffin | 8150da6 | 2019-12-16 17:21:27 +0000 | [diff] [blame] | 75 | } |