From ba791b18fbbfe421db859272dc19cbde55497632 Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Thu, 2 May 2024 16:40:08 +0000 Subject: [PATCH] Set strict_mode to true The default strict_mode is now set to true. We are encourage teams to write tests in strict_mode to make tests Bivalent (able to run on device and devicelessly) When opting out from strict_mode, "robolectric_strict_mode_res" should be included in lib for whitelisting purpose. Test: atest MyRoboTests Bug: 334089788 Change-Id: I3098e2c1ef1b5fd2ee1a98950db5e4f2e8d87d1e --- java/robolectric.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/java/robolectric.go b/java/robolectric.go index 18386c90c..cb22fa0db 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -116,7 +116,7 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { if v := String(r.robolectricProperties.Robolectric_prebuilt_version); v != "" { ctx.AddVariationDependencies(nil, libTag, fmt.Sprintf(robolectricPrebuiltLibPattern, v)) - } else if !proptools.Bool(r.robolectricProperties.Strict_mode) { + } else if !proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { if proptools.Bool(r.robolectricProperties.Upstream) { ctx.AddVariationDependencies(nil, libTag, robolectricCurrentLib+"_upstream") } else { @@ -124,8 +124,11 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { } } - if proptools.Bool(r.robolectricProperties.Strict_mode) { + if proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) { ctx.AddVariationDependencies(nil, roboRuntimeOnlyTag, robolectricCurrentLib+"_upstream") + } else { + // opting out from strict mode, robolectric_non_strict_mode_permission lib should be added + ctx.AddVariationDependencies(nil, libTag, "robolectric_non_strict_mode_permission") } ctx.AddVariationDependencies(nil, libTag, robolectricDefaultLibs...)