Merge "Separate system modules tests into their own file"

This commit is contained in:
Paul Duffin 2021-03-11 15:10:54 +00:00 committed by Gerrit Code Review
commit 8075291a94
3 changed files with 85 additions and 64 deletions

View File

@ -78,6 +78,7 @@ bootstrap_go_package {
"plugin_test.go", "plugin_test.go",
"rro_test.go", "rro_test.go",
"sdk_test.go", "sdk_test.go",
"system_modules_test.go",
], ],
pluginFor: ["soong_build"], pluginFor: ["soong_build"],
} }

View File

@ -2434,70 +2434,6 @@ func TestPatchModule(t *testing.T) {
}) })
} }
func TestJavaSystemModules(t *testing.T) {
ctx, _ := testJava(t, `
java_system_modules {
name: "system-modules",
libs: ["system-module1", "system-module2"],
}
java_library {
name: "system-module1",
srcs: ["a.java"],
sdk_version: "none",
system_modules: "none",
}
java_library {
name: "system-module2",
srcs: ["b.java"],
sdk_version: "none",
system_modules: "none",
}
`)
// check the existence of the module
systemModules := ctx.ModuleForTests("system-modules", "android_common")
cmd := systemModules.Rule("jarsTosystemModules")
// make sure the command compiles against the supplied modules.
for _, module := range []string{"system-module1.jar", "system-module2.jar"} {
if !strings.Contains(cmd.Args["classpath"], module) {
t.Errorf("system modules classpath %v does not contain %q", cmd.Args["classpath"],
module)
}
}
}
func TestJavaSystemModulesImport(t *testing.T) {
ctx, _ := testJava(t, `
java_system_modules_import {
name: "system-modules",
libs: ["system-module1", "system-module2"],
}
java_import {
name: "system-module1",
jars: ["a.jar"],
}
java_import {
name: "system-module2",
jars: ["b.jar"],
}
`)
// check the existence of the module
systemModules := ctx.ModuleForTests("system-modules", "android_common")
cmd := systemModules.Rule("jarsTosystemModules")
// make sure the command compiles against the supplied modules.
for _, module := range []string{"system-module1.jar", "system-module2.jar"} {
if !strings.Contains(cmd.Args["classpath"], module) {
t.Errorf("system modules classpath %v does not contain %q", cmd.Args["classpath"],
module)
}
}
}
func TestJavaLibraryWithSystemModules(t *testing.T) { func TestJavaLibraryWithSystemModules(t *testing.T) {
ctx, _ := testJava(t, ` ctx, _ := testJava(t, `
java_library { java_library {

View File

@ -0,0 +1,84 @@
// Copyright 2021 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package java
import (
"strings"
"testing"
)
func TestJavaSystemModules(t *testing.T) {
ctx, _ := testJava(t, `
java_system_modules {
name: "system-modules",
libs: ["system-module1", "system-module2"],
}
java_library {
name: "system-module1",
srcs: ["a.java"],
sdk_version: "none",
system_modules: "none",
}
java_library {
name: "system-module2",
srcs: ["b.java"],
sdk_version: "none",
system_modules: "none",
}
`)
// check the existence of the module
systemModules := ctx.ModuleForTests("system-modules", "android_common")
cmd := systemModules.Rule("jarsTosystemModules")
// make sure the command compiles against the supplied modules.
for _, module := range []string{"system-module1.jar", "system-module2.jar"} {
if !strings.Contains(cmd.Args["classpath"], module) {
t.Errorf("system modules classpath %v does not contain %q", cmd.Args["classpath"],
module)
}
}
}
func TestJavaSystemModulesImport(t *testing.T) {
ctx, _ := testJava(t, `
java_system_modules_import {
name: "system-modules",
libs: ["system-module1", "system-module2"],
}
java_import {
name: "system-module1",
jars: ["a.jar"],
}
java_import {
name: "system-module2",
jars: ["b.jar"],
}
`)
// check the existence of the module
systemModules := ctx.ModuleForTests("system-modules", "android_common")
cmd := systemModules.Rule("jarsTosystemModules")
// make sure the command compiles against the supplied modules.
for _, module := range []string{"system-module1.jar", "system-module2.jar"} {
if !strings.Contains(cmd.Args["classpath"], module) {
t.Errorf("system modules classpath %v does not contain %q", cmd.Args["classpath"],
module)
}
}
}