blob: d2fa2b152b9e13eb32f866bed232f75a6e4c36e9 [file] [log] [blame]
Paul Duffindb284be2021-03-11 08:07:46 +00001// 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
15package java
16
17import (
Paul Duffindb284be2021-03-11 08:07:46 +000018 "testing"
19)
20
21func TestJavaSystemModules(t *testing.T) {
Paul Duffinf23e3462021-03-11 08:14:44 +000022 result := javaFixtureFactory.RunTestWithBp(t, `
Paul Duffindb284be2021-03-11 08:07:46 +000023 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 Duffinf23e3462021-03-11 08:14:44 +000042 systemModules := result.ModuleForTests("system-modules", "android_common")
Paul Duffindb284be2021-03-11 08:07:46 +000043
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 Duffinf23e3462021-03-11 08:14:44 +000048 result.AssertStringDoesContain("system modules classpath", cmd.Args["classpath"], module)
Paul Duffindb284be2021-03-11 08:07:46 +000049 }
50}
51
52func TestJavaSystemModulesImport(t *testing.T) {
Paul Duffinf23e3462021-03-11 08:14:44 +000053 result := javaFixtureFactory.RunTestWithBp(t, `
Paul Duffindb284be2021-03-11 08:07:46 +000054 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 Duffinf23e3462021-03-11 08:14:44 +000069 systemModules := result.ModuleForTests("system-modules", "android_common")
Paul Duffindb284be2021-03-11 08:07:46 +000070
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 Duffinf23e3462021-03-11 08:14:44 +000075 result.AssertStringDoesContain("system modules classpath", cmd.Args["classpath"], module)
Paul Duffindb284be2021-03-11 08:07:46 +000076 }
77}