Refactor TestClasspath to simplify follow up change
Extracts classpathTestCase and extracts the logic for creating the test
into a separate testClasspathTestCases func.
Bug: 204189791
Test: m nothing
Change-Id: I657fbcde23a18f7f5651c174fbf17a9b7b7f1a9a
diff --git a/java/sdk_test.go b/java/sdk_test.go
index 28b9624..ed874e5 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -25,27 +25,29 @@
"android/soong/java/config"
)
+type classpathTestCase struct {
+ name string
+ unbundled bool
+ moduleType string
+ host android.OsClass
+ properties string
+
+ // for java 8
+ bootclasspath []string
+ java8classpath []string
+
+ // for java 9
+ system string
+ java9classpath []string
+
+ forces8 bool // if set, javac will always be called with java 8 arguments
+
+ aidl string
+}
+
func TestClasspath(t *testing.T) {
const frameworkAidl = "-I" + defaultJavaDir + "/framework/aidl"
- var classpathTestcases = []struct {
- name string
- unbundled bool
- moduleType string
- host android.OsClass
- properties string
-
- // for java 8
- bootclasspath []string
- java8classpath []string
-
- // for java 9
- system string
- java9classpath []string
-
- forces8 bool // if set, javac will always be called with java 8 arguments
-
- aidl string
- }{
+ var classpathTestcases = []classpathTestCase{
{
name: "default",
bootclasspath: config.StableCorePlatformBootclasspathLibraries,
@@ -295,6 +297,10 @@
},
}
+ testClasspathTestCases(t, classpathTestcases)
+}
+
+func testClasspathTestCases(t *testing.T, classpathTestcases []classpathTestCase) {
for _, testcase := range classpathTestcases {
t.Run(testcase.name, func(t *testing.T) {
moduleType := "java_library"