Loading android/module.go +35 −21 Original line number Diff line number Diff line Loading @@ -936,6 +936,20 @@ type distProperties struct { Dists []Dist `android:"arch_variant"` } // CommonTestOptions represents the common `test_options` properties in // Android.bp. type CommonTestOptions struct { // If the test is a hostside (no device required) unittest that shall be run // during presubmit check. Unit_test *bool } // SetAndroidMkEntries sets AndroidMkEntries according to the value of base // `test_options`. func (t *CommonTestOptions) SetAndroidMkEntries(entries *AndroidMkEntries) { entries.SetBoolIfTrue("LOCAL_IS_UNIT_TEST", Bool(t.Unit_test)) } // The key to use in TaggedDistFiles when a Dist structure does not specify a // tag property. This intentionally does not use "" as the default because that // would mean that an empty tag would have a different meaning when used in a dist Loading android/module_test.go +42 −0 Original line number Diff line number Diff line Loading @@ -911,3 +911,45 @@ func TestSortedUniqueNamedPaths(t *testing.T) { }) } } func TestProcessCommonTestOptions(t *testing.T) { tests := []struct { name string testOptions CommonTestOptions expected map[string][]string }{ { name: "empty", testOptions: CommonTestOptions{}, expected: map[string][]string{}, }, { name: "is unit test", testOptions: CommonTestOptions{ Unit_test: boolPtr(true), }, expected: map[string][]string{ "LOCAL_IS_UNIT_TEST": []string{"true"}, }, }, { name: "is not unit test", testOptions: CommonTestOptions{ Unit_test: boolPtr(false), }, expected: map[string][]string{}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { actualEntries := AndroidMkEntries{ EntryMap: map[string][]string{}, } tt.testOptions.SetAndroidMkEntries(&actualEntries) actual := actualEntries.EntryMap t.Logf("actual: %v", actual) t.Logf("expected: %v", tt.expected) AssertDeepEquals(t, "TestProcessCommonTestOptions ", tt.expected, actual) }) } } cc/androidmk.go +2 −3 Original line number Diff line number Diff line Loading @@ -411,14 +411,13 @@ func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android. entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true) } entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...) if Bool(test.Properties.Test_options.Unit_test) { entries.SetBool("LOCAL_IS_UNIT_TEST", true) } entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(test.Properties.Per_testcase_directory)) if len(test.Properties.Data_bins) > 0 { entries.AddStrings("LOCAL_TEST_DATA_BINS", test.Properties.Data_bins...) } test.Properties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries) }) AndroidMkWriteTestData(test.data, entries) Loading cc/test.go +2 −3 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ type TestInstallerProperties struct { // Test option struct. type TestOptions struct { android.CommonTestOptions // The UID that you want to run the test as on a device. Run_test_as *string Loading @@ -52,9 +54,6 @@ type TestOptions struct { // a list of extra test configuration files that should be installed with the module. Extra_test_configs []string `android:"path,arch_variant"` // If the test is a hostside(no device required) unittest that shall be run during presubmit check. Unit_test *bool // Add ShippingApiLevelModuleController to auto generated test config. If the device properties // for the shipping api level is less than the min_shipping_api_level, skip this module. Min_shipping_api_level *int64 Loading java/androidmk.go +2 −3 Original line number Diff line number Diff line Loading @@ -167,9 +167,8 @@ func (j *Test) AndroidMkEntries() []android.AndroidMkEntries { entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true") } entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...) if Bool(j.testProperties.Test_options.Unit_test) { entries.SetBool("LOCAL_IS_UNIT_TEST", true) } j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries) }) return entriesList Loading Loading
android/module.go +35 −21 Original line number Diff line number Diff line Loading @@ -936,6 +936,20 @@ type distProperties struct { Dists []Dist `android:"arch_variant"` } // CommonTestOptions represents the common `test_options` properties in // Android.bp. type CommonTestOptions struct { // If the test is a hostside (no device required) unittest that shall be run // during presubmit check. Unit_test *bool } // SetAndroidMkEntries sets AndroidMkEntries according to the value of base // `test_options`. func (t *CommonTestOptions) SetAndroidMkEntries(entries *AndroidMkEntries) { entries.SetBoolIfTrue("LOCAL_IS_UNIT_TEST", Bool(t.Unit_test)) } // The key to use in TaggedDistFiles when a Dist structure does not specify a // tag property. This intentionally does not use "" as the default because that // would mean that an empty tag would have a different meaning when used in a dist Loading
android/module_test.go +42 −0 Original line number Diff line number Diff line Loading @@ -911,3 +911,45 @@ func TestSortedUniqueNamedPaths(t *testing.T) { }) } } func TestProcessCommonTestOptions(t *testing.T) { tests := []struct { name string testOptions CommonTestOptions expected map[string][]string }{ { name: "empty", testOptions: CommonTestOptions{}, expected: map[string][]string{}, }, { name: "is unit test", testOptions: CommonTestOptions{ Unit_test: boolPtr(true), }, expected: map[string][]string{ "LOCAL_IS_UNIT_TEST": []string{"true"}, }, }, { name: "is not unit test", testOptions: CommonTestOptions{ Unit_test: boolPtr(false), }, expected: map[string][]string{}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { actualEntries := AndroidMkEntries{ EntryMap: map[string][]string{}, } tt.testOptions.SetAndroidMkEntries(&actualEntries) actual := actualEntries.EntryMap t.Logf("actual: %v", actual) t.Logf("expected: %v", tt.expected) AssertDeepEquals(t, "TestProcessCommonTestOptions ", tt.expected, actual) }) } }
cc/androidmk.go +2 −3 Original line number Diff line number Diff line Loading @@ -411,14 +411,13 @@ func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android. entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true) } entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...) if Bool(test.Properties.Test_options.Unit_test) { entries.SetBool("LOCAL_IS_UNIT_TEST", true) } entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(test.Properties.Per_testcase_directory)) if len(test.Properties.Data_bins) > 0 { entries.AddStrings("LOCAL_TEST_DATA_BINS", test.Properties.Data_bins...) } test.Properties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries) }) AndroidMkWriteTestData(test.data, entries) Loading
cc/test.go +2 −3 Original line number Diff line number Diff line Loading @@ -43,6 +43,8 @@ type TestInstallerProperties struct { // Test option struct. type TestOptions struct { android.CommonTestOptions // The UID that you want to run the test as on a device. Run_test_as *string Loading @@ -52,9 +54,6 @@ type TestOptions struct { // a list of extra test configuration files that should be installed with the module. Extra_test_configs []string `android:"path,arch_variant"` // If the test is a hostside(no device required) unittest that shall be run during presubmit check. Unit_test *bool // Add ShippingApiLevelModuleController to auto generated test config. If the device properties // for the shipping api level is less than the min_shipping_api_level, skip this module. Min_shipping_api_level *int64 Loading
java/androidmk.go +2 −3 Original line number Diff line number Diff line Loading @@ -167,9 +167,8 @@ func (j *Test) AndroidMkEntries() []android.AndroidMkEntries { entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true") } entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", j.testProperties.Test_mainline_modules...) if Bool(j.testProperties.Test_options.Unit_test) { entries.SetBool("LOCAL_IS_UNIT_TEST", true) } j.testProperties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries) }) return entriesList Loading