summaryrefslogtreecommitdiff
path: root/android/testing.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-08-08 15:50:47 -0700
committer Colin Cross <ccross@android.com> 2024-08-09 16:47:45 -0700
commita66b4630f60847c216699831b99aeb905362ccda (patch)
treef67e64ab0206908cbd5155f74b35b43d6271c26b /android/testing.go
parent788f69722c2fb02bad642d7b5e4bb30a2fa6e86a (diff)
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
Diffstat (limited to 'android/testing.go')
-rw-r--r--android/testing.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/android/testing.go b/android/testing.go
index dae787b7f..e3853b844 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -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)