Refactor and strengthen sdk_test.go.
This change: - Removes usage of the EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9=false option from tests, since it is going to be removed. The java_version property is used instead. - Commons up some of the assertions between the tests for language levels 8 and 9 in sdk_test.go. - In commoning the code up, some additional assertions are made in the language level 9 cases, strengthening the tests. Test: m nothing Bug: 115604102 Change-Id: I693c5d299b5592b851c44dde4434d92a931f15cd
This commit is contained in:
@@ -1073,32 +1073,32 @@ func checkPatchModuleFlag(t *testing.T, ctx *android.TestContext, moduleName str
|
||||
}
|
||||
|
||||
func TestPatchModule(t *testing.T) {
|
||||
bp := `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["b.java"],
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
patch_module: "java.base",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "baz",
|
||||
srcs: ["c.java"],
|
||||
patch_module: "java.base",
|
||||
}
|
||||
`
|
||||
|
||||
t.Run("Java language level 8", func(t *testing.T) {
|
||||
// Test with legacy javac -source 1.8 -target 1.8
|
||||
config := testConfig(map[string]string{"EXPERIMENTAL_JAVA_LANGUAGE_LEVEL_9": "false"})
|
||||
ctx := testContext(bp, nil)
|
||||
run(t, ctx, config)
|
||||
bp := `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
java_version: "1.8",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["b.java"],
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
patch_module: "java.base",
|
||||
java_version: "1.8",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "baz",
|
||||
srcs: ["c.java"],
|
||||
patch_module: "java.base",
|
||||
java_version: "1.8",
|
||||
}
|
||||
`
|
||||
ctx, _ := testJava(t, bp)
|
||||
|
||||
checkPatchModuleFlag(t, ctx, "foo", "")
|
||||
checkPatchModuleFlag(t, ctx, "bar", "")
|
||||
@@ -1107,6 +1107,26 @@ func TestPatchModule(t *testing.T) {
|
||||
|
||||
t.Run("Java language level 9", func(t *testing.T) {
|
||||
// Test with default javac -source 9 -target 9
|
||||
bp := `
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["a.java"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["b.java"],
|
||||
sdk_version: "none",
|
||||
system_modules: "none",
|
||||
patch_module: "java.base",
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "baz",
|
||||
srcs: ["c.java"],
|
||||
patch_module: "java.base",
|
||||
}
|
||||
`
|
||||
ctx, _ := testJava(t, bp)
|
||||
|
||||
checkPatchModuleFlag(t, ctx, "foo", "")
|
||||
|
Reference in New Issue
Block a user