diff options
author | 2020-04-25 21:40:35 -0700 | |
---|---|---|
committer | 2020-08-04 18:57:10 +0000 | |
commit | 02a623d8d399b7d7981040e173a2f5e14d41ae5f (patch) | |
tree | 54818de2ce9062febbfecc22fb2f1c73a6551cb1 /rust | |
parent | 89e4882d3764dc5c749a630b22381d9ead761500 (diff) |
Make Rust test harness optional for test binaries
Adds a test_harness field to Rust test blueprint properties. If this
field is explicitly set to false, do not build the test binary with
`--test`. This is necessary for Rust tests which cannot use the standard
test harness.
Test: atest rustBinderTest
Test: atest --host proc-macro2_tests_test
Change-Id: Icbcb54422cc716348feae56b2d71f013516b0ac0
Diffstat (limited to 'rust')
-rw-r--r-- | rust/test.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/rust/test.go b/rust/test.go index e27a70cac..05c361e87 100644 --- a/rust/test.go +++ b/rust/test.go @@ -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 } |