blob: 173ccb92542013282744017de763a578fd94c19b [file] [log] [blame]
Paul Duffin8150da62019-12-16 17:21:27 +00001// 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
15package sdk
16
17import (
18 "testing"
19)
20
21// Ensure that module_exports generates a module_exports_snapshot module.
22func TestModuleExportsSnapshot(t *testing.T) {
Colin Cross323dc602020-09-18 14:25:31 -070023 t.Parallel()
Paul Duffin8150da62019-12-16 17:21:27 +000024 packageBp := `
25 module_exports {
26 name: "myexports",
27 java_libs: [
28 "myjavalib",
29 ],
30 }
31
32 java_library {
33 name: "myjavalib",
34 srcs: ["Test.java"],
35 system_modules: "none",
36 sdk_version: "none",
37 }
38 `
39
40 result := testSdkWithFs(t, ``,
41 map[string][]byte{
42 "package/Test.java": nil,
43 "package/Android.bp": []byte(packageBp),
44 })
45
Paul Duffin1356d8c2020-02-25 19:26:33 +000046 result.CheckSnapshot("myexports", "package",
Paul Duffin8150da62019-12-16 17:21:27 +000047 checkAndroidBpContents(`
48// This is auto-generated. DO NOT EDIT.
49
50java_import {
51 name: "myexports_myjavalib@current",
52 sdk_member_name: "myjavalib",
Paul Duffind99d9972020-09-29 16:00:55 +010053 visibility: ["//visibility:public"],
Paul Duffin8150da62019-12-16 17:21:27 +000054 jars: ["java/myjavalib.jar"],
55}
56
57java_import {
58 name: "myjavalib",
59 prefer: false,
Paul Duffind99d9972020-09-29 16:00:55 +010060 visibility: ["//visibility:public"],
Paul Duffin8150da62019-12-16 17:21:27 +000061 jars: ["java/myjavalib.jar"],
62}
63
64module_exports_snapshot {
65 name: "myexports@current",
Paul Duffind99d9972020-09-29 16:00:55 +010066 visibility: ["//visibility:public"],
Paul Duffin8150da62019-12-16 17:21:27 +000067 java_libs: ["myexports_myjavalib@current"],
68}
69`))
70}