summaryrefslogtreecommitdiff
path: root/rust/test.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2021-01-29 12:48:05 -0500
committer Ivan Lozano <ivanlozano@google.com> 2021-01-29 14:31:32 -0500
commit9da4aa8166efe67d6c4ab1fe7911224d94493cc9 (patch)
tree655955ac8c4e54abea372e9499c642d00f7c5f50 /rust/test.go
parent9436be43216d152265187c6d2eece38f9a10a9a7 (diff)
rust: Allow rust_tests to include data files.
Adds the ability to define data files that should be installed alongside the test. This also fixes a bug wherein rust_test properties were duplicated. Bug: 171710847 Test: rust_test module with "data" property installs files to device. Change-Id: I091489afaf7e76b751a33a28049590d9fb39fe5f
Diffstat (limited to 'rust/test.go')
-rw-r--r--rust/test.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/rust/test.go b/rust/test.go
index 35e04fff6..92b486070 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -43,6 +43,10 @@ type TestProperties struct {
// installed into.
Test_suites []string `android:"arch_variant"`
+ // list of files or filegroup modules that provide data that should be installed alongside
+ // the test
+ Data []string `android:"path,arch_variant"`
+
// Flag to indicate whether or not to create test config automatically. If AndroidTest.xml
// doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
// explicitly.
@@ -62,6 +66,12 @@ type testDecorator struct {
*binaryDecorator
Properties TestProperties
testConfig android.Path
+
+ data []android.DataPath
+}
+
+func (test *testDecorator) dataPaths() []android.DataPath {
+ return test.data
}
func (test *testDecorator) nativeCoverage() bool {
@@ -89,7 +99,6 @@ func NewRustTest(hod android.HostOrDeviceSupported) (*Module, *testDecorator) {
}
module.compiler = test
- module.AddProperties(&test.Properties)
return module, test
}
@@ -105,6 +114,12 @@ func (test *testDecorator) install(ctx ModuleContext) {
nil,
test.Properties.Auto_gen_config)
+ dataSrcPaths := android.PathsForModuleSrc(ctx, test.Properties.Data)
+
+ for _, dataSrcPath := range dataSrcPaths {
+ test.data = append(test.data, android.DataPath{SrcPath: dataSrcPath})
+ }
+
// default relative install path is module name
if !Bool(test.Properties.No_named_install_directory) {
test.baseCompiler.relative = ctx.ModuleName()