From bdf5d7170ac859e28f458c1d46c2b2494061de3f Mon Sep 17 00:00:00 2001 From: Pete Gillin Date: Mon, 21 Oct 2019 14:29:58 +0100 Subject: 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 --- java/java_test.go | 68 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 24 deletions(-) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index a3499ccd8..3767d1b24 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -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", "") -- cgit v1.2.3-59-g8ed1b