Merge "Remove incorrect strict test for test-suites for test_module_config" into main am: d58ac5358d

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3066624

Change-Id: I54aea2e7d6b23d4111b729d9b8d9a763f989f9a1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2024-04-30 20:26:42 +00:00
committed by Automerger Merge Worker
2 changed files with 5 additions and 47 deletions

View File

@@ -160,35 +160,17 @@ func (m *testModuleConfigModule) GenerateAndroidBuildActions(ctx android.ModuleC
}
// Any test suites in base should not be repeated in the derived class, except "general-tests".
// We may restrict derived tests to only be "general-tests" as it doesn't make sense to add a slice
// of a test to compatibility suite.
// Ensure at least one test_suite is listed. Ideally it should be general-tests
// or device-tests, whichever is listed in base and prefer general-tests if both are listed.
// However this is not enforced yet.
//
// Returns ErrorMessage, false on problems
// Returns _, true if okay.
// Returns true if okay and reports errors via ModuleErrorf.
func (m *testModuleConfigModule) validateTestSuites(ctx android.ModuleContext) bool {
if len(m.tradefedProperties.Test_suites) == 0 {
ctx.ModuleErrorf("At least one test-suite must be set or this won't run. Use \"general-tests\"")
ctx.ModuleErrorf("At least one test-suite must be set or this won't run. Use \"general-tests\" or \"device-tests\"")
return false
}
derivedSuites := make(map[string]bool)
// See if any suites in base is also in derived (other than general-tests)
for _, s := range m.tradefedProperties.Test_suites {
if s != "general-tests" {
derivedSuites[s] = true
}
}
if len(derivedSuites) == 0 {
return true
}
for _, baseSuite := range m.provider.TestSuites {
if derivedSuites[baseSuite] {
ctx.ModuleErrorf("TestSuite %s exists in the base, do not add it here", baseSuite)
return false
}
}
return true
}

View File

@@ -325,30 +325,6 @@ func TestModuleConfigHostNeedsATestSuite(t *testing.T) {
RunTestWithBp(t, badBp)
}
func TestModuleConfigHostDuplicateTestSuitesGiveErrors(t *testing.T) {
badBp := `
java_test_host {
name: "base",
srcs: ["a.java"],
test_suites: ["general-tests", "some-compat"],
}
test_module_config_host {
name: "derived_test",
base: "base",
exclude_filters: ["android.test.example.devcodelab.DevCodelabTest#testHelloFail"],
include_annotations: ["android.platform.test.annotations.LargeTest"],
test_suites: ["general-tests", "some-compat"],
}`
android.GroupFixturePreparers(
java.PrepareForTestWithJavaDefaultModules,
android.FixtureRegisterWithContext(RegisterTestModuleConfigBuildComponents),
).ExtendWithErrorHandler(
android.FixtureExpectsAtLeastOneErrorMatchingPattern("TestSuite some-compat exists in the base")).
RunTestWithBp(t, badBp)
}
func TestTestOnlyProvider(t *testing.T) {
t.Parallel()
ctx := android.GroupFixturePreparers(