Add PrepareForTestWithBuildFlag

Add a helper function that creates a test fixture preparer that
sets a build flag, and use it everywhere that was setting build flags
manually.

Test: all soong tests
Flag: EXEMPT refactor
Change-Id: I68d50d68787a30d091f0827e8caa51f5c5a762ef
This commit is contained in:
Colin Cross
2024-08-08 15:50:47 -07:00
parent 788f69722c
commit a66b4630f6
18 changed files with 49 additions and 180 deletions

View File

@@ -174,6 +174,16 @@ var PrepareForTestDisallowNonExistentPaths = FixtureModifyConfig(func(config Con
config.TestAllowNonExistentPaths = false
})
// PrepareForTestWithBuildFlag returns a FixturePreparer that sets the given flag to the given value.
func PrepareForTestWithBuildFlag(flag, value string) FixturePreparer {
return FixtureModifyProductVariables(func(variables FixtureProductVariables) {
if variables.BuildFlags == nil {
variables.BuildFlags = make(map[string]string)
}
variables.BuildFlags[flag] = value
})
}
func NewTestArchContext(config Config) *TestContext {
ctx := NewTestContext(config)
ctx.preDeps = append(ctx.preDeps, registerArchMutator)