Paul Duffin | db284be | 2021-03-11 08:07:46 +0000 | [diff] [blame] | 1 | // Copyright 2021 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 java |
| 16 | |
| 17 | import ( |
Paul Duffin | db284be | 2021-03-11 08:07:46 +0000 | [diff] [blame] | 18 | "testing" |
| 19 | ) |
| 20 | |
| 21 | func TestJavaSystemModules(t *testing.T) { |
Paul Duffin | f23e346 | 2021-03-11 08:14:44 +0000 | [diff] [blame^] | 22 | result := javaFixtureFactory.RunTestWithBp(t, ` |
Paul Duffin | db284be | 2021-03-11 08:07:46 +0000 | [diff] [blame] | 23 | java_system_modules { |
| 24 | name: "system-modules", |
| 25 | libs: ["system-module1", "system-module2"], |
| 26 | } |
| 27 | java_library { |
| 28 | name: "system-module1", |
| 29 | srcs: ["a.java"], |
| 30 | sdk_version: "none", |
| 31 | system_modules: "none", |
| 32 | } |
| 33 | java_library { |
| 34 | name: "system-module2", |
| 35 | srcs: ["b.java"], |
| 36 | sdk_version: "none", |
| 37 | system_modules: "none", |
| 38 | } |
| 39 | `) |
| 40 | |
| 41 | // check the existence of the module |
Paul Duffin | f23e346 | 2021-03-11 08:14:44 +0000 | [diff] [blame^] | 42 | systemModules := result.ModuleForTests("system-modules", "android_common") |
Paul Duffin | db284be | 2021-03-11 08:07:46 +0000 | [diff] [blame] | 43 | |
| 44 | cmd := systemModules.Rule("jarsTosystemModules") |
| 45 | |
| 46 | // make sure the command compiles against the supplied modules. |
| 47 | for _, module := range []string{"system-module1.jar", "system-module2.jar"} { |
Paul Duffin | f23e346 | 2021-03-11 08:14:44 +0000 | [diff] [blame^] | 48 | result.AssertStringDoesContain("system modules classpath", cmd.Args["classpath"], module) |
Paul Duffin | db284be | 2021-03-11 08:07:46 +0000 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestJavaSystemModulesImport(t *testing.T) { |
Paul Duffin | f23e346 | 2021-03-11 08:14:44 +0000 | [diff] [blame^] | 53 | result := javaFixtureFactory.RunTestWithBp(t, ` |
Paul Duffin | db284be | 2021-03-11 08:07:46 +0000 | [diff] [blame] | 54 | java_system_modules_import { |
| 55 | name: "system-modules", |
| 56 | libs: ["system-module1", "system-module2"], |
| 57 | } |
| 58 | java_import { |
| 59 | name: "system-module1", |
| 60 | jars: ["a.jar"], |
| 61 | } |
| 62 | java_import { |
| 63 | name: "system-module2", |
| 64 | jars: ["b.jar"], |
| 65 | } |
| 66 | `) |
| 67 | |
| 68 | // check the existence of the module |
Paul Duffin | f23e346 | 2021-03-11 08:14:44 +0000 | [diff] [blame^] | 69 | systemModules := result.ModuleForTests("system-modules", "android_common") |
Paul Duffin | db284be | 2021-03-11 08:07:46 +0000 | [diff] [blame] | 70 | |
| 71 | cmd := systemModules.Rule("jarsTosystemModules") |
| 72 | |
| 73 | // make sure the command compiles against the supplied modules. |
| 74 | for _, module := range []string{"system-module1.jar", "system-module2.jar"} { |
Paul Duffin | f23e346 | 2021-03-11 08:14:44 +0000 | [diff] [blame^] | 75 | result.AssertStringDoesContain("system modules classpath", cmd.Args["classpath"], module) |
Paul Duffin | db284be | 2021-03-11 08:07:46 +0000 | [diff] [blame] | 76 | } |
| 77 | } |