diff options
Diffstat (limited to 'python/test.go')
-rw-r--r-- | python/test.go | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/python/test.go b/python/test.go index a669c73a6..6713189fd 100644 --- a/python/test.go +++ b/python/test.go @@ -22,8 +22,18 @@ import ( // This file contains the module types for building Python test. func init() { - android.RegisterModuleType("python_test_host", PythonTestHostFactory) - android.RegisterModuleType("python_test", PythonTestFactory) + registerPythonTestComponents(android.InitRegistrationContext) +} + +func registerPythonTestComponents(ctx android.RegistrationContext) { + ctx.RegisterModuleType("python_test_host", PythonTestHostFactory) + ctx.RegisterModuleType("python_test", PythonTestFactory) +} + +// Test option struct. +type TestOptions struct { + // If the test is a hostside(no device required) unittest that shall be run during presubmit check. + Unit_test *bool } type TestProperties struct { @@ -34,6 +44,16 @@ type TestProperties struct { // the name of the test configuration template (for example "AndroidTestTemplate.xml") that // should be installed with the module. Test_config_template *string `android:"path,arch_variant"` + + // list of files or filegroup modules that provide data that should be installed alongside + // the test + Data []string `android:"path,arch_variant"` + + // list of java modules that provide data that should be installed alongside the test. + Java_data []string + + // Test options. + Test_options TestOptions } type testDecorator struct { @@ -42,6 +62,8 @@ type testDecorator struct { testProperties TestProperties testConfig android.Path + + data []android.DataPath } func (test *testDecorator) bootstrapperProps() []interface{} { @@ -59,6 +81,19 @@ func (test *testDecorator) install(ctx android.ModuleContext, file android.Path) test.binaryDecorator.pythonInstaller.relative = ctx.ModuleName() test.binaryDecorator.pythonInstaller.install(ctx, file) + + dataSrcPaths := android.PathsForModuleSrc(ctx, test.testProperties.Data) + + for _, dataSrcPath := range dataSrcPaths { + test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath}) + } + + // Emulate the data property for java_data dependencies. + for _, javaData := range ctx.GetDirectDepsWithTag(javaDataTag) { + for _, javaDataSrcPath := range android.OutputFilesForModule(ctx, javaData, "") { + test.data = append(test.data, android.DataPath{SrcPath: javaDataSrcPath}) + } + } } func NewTest(hod android.HostOrDeviceSupported) *Module { @@ -77,12 +112,12 @@ func NewTest(hod android.HostOrDeviceSupported) *Module { func PythonTestHostFactory() android.Module { module := NewTest(android.HostSupportedNoCross) - return module.Init() + return module.init() } func PythonTestFactory() android.Module { module := NewTest(android.HostAndDeviceSupported) module.multilib = android.MultilibBoth - return module.Init() + return module.init() } |