From 0b3b36a4027a7456f765b85fd819a4d26ed50795 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 28 Oct 2021 18:05:53 +0100 Subject: [PATCH] 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 --- java/sdk_test.go | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/java/sdk_test.go b/java/sdk_test.go index 28b962432..ed874e543 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -25,27 +25,29 @@ import ( "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 @@ func TestClasspath(t *testing.T) { }, } + 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"