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:
Pete Gillin
2019-10-21 14:29:58 +01:00
parent 8436ccea9c
commit bdf5d7170a
2 changed files with 103 additions and 59 deletions

View File

@@ -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", "")