Merge "Make Rust test harness optional for test binaries"

This commit is contained in:
Matthew Maurer 2020-08-05 21:26:45 +00:00 committed by Gerrit Code Review
commit 53bba5de8a
1 changed files with 10 additions and 1 deletions

View File

@ -41,6 +41,9 @@ type TestProperties struct {
// doesn't exist next to the Android.bp, this attribute doesn't need to be set to true
// explicitly.
Auto_gen_config *bool
// if set, build with the standard Rust test harness. Defaults to true.
Test_harness *bool
}
// A test module is a binary module with extra --test compiler flag
@ -56,6 +59,10 @@ func (test *testDecorator) nativeCoverage() bool {
return true
}
func (test *testDecorator) testHarness() bool {
return BoolDefault(test.Properties.Test_harness, true)
}
func NewRustTest(hod android.HostOrDeviceSupported) (*Module, *testDecorator) {
// Build both 32 and 64 targets for device tests.
// Cannot build both for host tests yet if the test depends on
@ -101,7 +108,9 @@ func (test *testDecorator) install(ctx ModuleContext, file android.Path) {
func (test *testDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags {
flags = test.binaryDecorator.compilerFlags(ctx, flags)
flags.RustFlags = append(flags.RustFlags, "--test")
if test.testHarness() {
flags.RustFlags = append(flags.RustFlags, "--test")
}
return flags
}