Romain Jobredeaux | 428a366 | 2022-01-28 11:12:52 -0500 | [diff] [blame^] | 1 | // Copyright 2022 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 bp2build |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "android/soong/java" |
| 20 | |
| 21 | "testing" |
| 22 | ) |
| 23 | |
| 24 | func runJavaImportTestCase(t *testing.T, tc bp2buildTestCase) { |
| 25 | t.Helper() |
| 26 | runBp2BuildTestCase(t, registerJavaImportModuleTypes, tc) |
| 27 | } |
| 28 | |
| 29 | func registerJavaImportModuleTypes(ctx android.RegistrationContext) { |
| 30 | } |
| 31 | |
| 32 | func TestMinimalJavaImport(t *testing.T) { |
| 33 | runJavaImportTestCase(t, bp2buildTestCase{ |
| 34 | description: "Java import - simple example", |
| 35 | moduleTypeUnderTest: "java_import", |
| 36 | moduleTypeUnderTestFactory: java.ImportFactory, |
| 37 | filesystem: map[string]string{ |
| 38 | "import.jar": "", |
| 39 | }, |
| 40 | blueprint: ` |
| 41 | java_import { |
| 42 | name: "example_import", |
| 43 | jars: ["import.jar"], |
| 44 | bazel_module: { bp2build_available: true }, |
| 45 | } |
| 46 | `, |
| 47 | expectedBazelTargets: []string{ |
| 48 | makeBazelTarget("java_import", "example_import", attrNameToString{ |
| 49 | "jars": `["import.jar"]`, |
| 50 | }), |
| 51 | }}) |
| 52 | } |