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

Commit 8440f9d2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Stop using _upstream suffix, and remove visibility checks on...

Merge "Stop using _upstream suffix, and remove visibility checks on ClearcutJunitListener." into main
parents e62022dc 39e3e08e
Loading
Loading
Loading
Loading
+18 −19
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ import (
	"android/soong/android"
	"android/soong/java/config"
	"android/soong/tradefed"

	"github.com/google/blueprint"
	"github.com/google/blueprint/proptools"
)

@@ -28,6 +28,17 @@ func init() {
	RegisterRobolectricBuildComponents(android.InitRegistrationContext)
}

type roboRuntimeOnlyDependencyTag struct {
	blueprint.BaseDependencyTag
}

var roboRuntimeOnlyDepTag roboRuntimeOnlyDependencyTag

// Mark this tag so dependencies that use it are excluded from visibility enforcement.
func (t roboRuntimeOnlyDependencyTag) ExcludeFromVisibilityEnforcement() {}

var _ android.ExcludeFromVisibilityEnforcementTag = roboRuntimeOnlyDepTag

func RegisterRobolectricBuildComponents(ctx android.RegistrationContext) {
	ctx.RegisterModuleType("android_robolectric_test", RobolectricTestFactory)
	ctx.RegisterModuleType("android_robolectric_runtimes", robolectricRuntimesFactory)
@@ -47,7 +58,6 @@ const robolectricPrebuiltLibPattern = "platform-robolectric-%s-prebuilt"
var (
	roboCoverageLibsTag = dependencyTag{name: "roboCoverageLibs"}
	roboRuntimesTag     = dependencyTag{name: "roboRuntimes"}
	roboRuntimeOnlyTag  = dependencyTag{name: "roboRuntimeOnlyTag"}
)

type robolectricProperties struct {
@@ -65,10 +75,6 @@ type robolectricProperties struct {
		Shards *int64
	}

	// The version number of a robolectric prebuilt to use from prebuilts/misc/common/robolectric
	// instead of the one built from source in external/robolectric-shadows.
	Robolectric_prebuilt_version *string

	// Use /external/robolectric rather than /external/robolectric-shadows as the version of robolectric
	// to use.  /external/robolectric closely tracks github's master, and will fully replace /external/robolectric-shadows
	Upstream *bool
@@ -98,6 +104,8 @@ func (r *robolectricTest) TestSuites() []string {

var _ android.TestSuiteModule = (*robolectricTest)(nil)



func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) {
	r.Library.DepsMutator(ctx)

@@ -107,21 +115,12 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) {
		ctx.PropertyErrorf("instrumentation_for", "missing required instrumented module")
	}

	ctx.AddVariationDependencies(nil, staticLibTag, clearcutJunitLib)

	if v := String(r.robolectricProperties.Robolectric_prebuilt_version); v != "" {
		ctx.AddVariationDependencies(nil, staticLibTag, fmt.Sprintf(robolectricPrebuiltLibPattern, v))
	} else if !proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) {
		if proptools.Bool(r.robolectricProperties.Upstream) {
			ctx.AddVariationDependencies(nil, staticLibTag, robolectricCurrentLib+"_upstream")
		} else {
			ctx.AddVariationDependencies(nil, staticLibTag, robolectricCurrentLib)
		}
	}
	ctx.AddVariationDependencies(nil, roboRuntimeOnlyDepTag, clearcutJunitLib)

	if proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) {
		ctx.AddVariationDependencies(nil, roboRuntimeOnlyTag, robolectricCurrentLib+"_upstream")
		ctx.AddVariationDependencies(nil, roboRuntimeOnlyDepTag, robolectricCurrentLib)
	} else {
		ctx.AddVariationDependencies(nil, staticLibTag, robolectricCurrentLib)
		// opting out from strict mode, robolectric_non_strict_mode_permission lib should be added
		ctx.AddVariationDependencies(nil, staticLibTag, "robolectric_non_strict_mode_permission")
	}
@@ -197,7 +196,7 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
		handleLibDeps(dep)
	}
	// handle the runtimeOnly tag for strict_mode
	for _, dep := range ctx.GetDirectDepsWithTag(roboRuntimeOnlyTag) {
	for _, dep := range ctx.GetDirectDepsWithTag(roboRuntimeOnlyDepTag) {
		handleLibDeps(dep)
	}

+5 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@ var prepareRobolectricRuntime = android.GroupFixturePreparers(
		srcs: ["Robo.java"]
	}

	java_library {
		name: "Robolectric_all-target",
		srcs: ["Robo.java"]
	}

	java_library {
		name: "mockito-robolectric-prebuilt",
		srcs: ["Mockito.java"]