Enforce that tests in MTS specify a min_sdk_version

Specifying min_sdk_version ensures backwards compatibility. There are
some existing violations, and those have been baseline'd using an
allowlist.

Bug: 156476221
Test: m nothing
Change-Id: I55098206da8ec5cfa0a9f5e7b41c9b8dedbdcbd2
This commit is contained in:
Spandan Das
2024-06-25 03:30:03 +00:00
parent d6352efd1a
commit b041087f58
4 changed files with 36 additions and 2 deletions

View File

@@ -71,12 +71,15 @@ func shouldReturnFinalOrFutureInt(ctx android.ModuleContext, targetSdkVersionLev
return targetSdkVersionLevel.IsPreview() && (ctx.Config().UnbundledBuildApps() || includedInMts(ctx.Module()))
}
// Helper function that casts android.Module to java.androidTestApp
// If this type conversion is possible, it queries whether the test app is included in an MTS suite
// Helper function that returns true if android_test, android_test_helper_app, java_test are in an MTS suite.
func includedInMts(module android.Module) bool {
if test, ok := module.(androidTestApp); ok {
return test.includedInTestSuite("mts")
}
// java_test
if test, ok := module.(*Test); ok {
return android.PrefixInList(test.testProperties.Test_suites, "mts")
}
return false
}