Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a66325b authored by Matthew Maurer's avatar Matthew Maurer Committed by Automerger Merge Worker
Browse files

Merge "Make Rust test harness optional for test binaries" am: 53bba5de am:...

Merge "Make Rust test harness optional for test binaries" am: 53bba5de am: b32f2b34 am: 97f1fae5

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1295711

Change-Id: Ie4adc709de4110113a75d94a59e4aaa32344d079
parents 4ff5dfc7 97f1fae5
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -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)
	if test.testHarness() {
		flags.RustFlags = append(flags.RustFlags, "--test")
	}
	return flags
}