Merge "Support robolectric prebuilts in android_robolectric_test" am: 7314fedd37
am: d5e78d1c17
am: 6426ae5a73
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1621781 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I6ac0e29ee43926bf07ba918a477dbef1389f643c
This commit is contained in:
commit
7b6db9b717
1 changed files with 18 additions and 2 deletions
|
@ -31,13 +31,15 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var robolectricDefaultLibs = []string{
|
var robolectricDefaultLibs = []string{
|
||||||
"Robolectric_all-target",
|
|
||||||
"mockito-robolectric-prebuilt",
|
"mockito-robolectric-prebuilt",
|
||||||
"truth-prebuilt",
|
"truth-prebuilt",
|
||||||
// TODO(ccross): this is not needed at link time
|
// TODO(ccross): this is not needed at link time
|
||||||
"junitxml",
|
"junitxml",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const robolectricCurrentLib = "Robolectric_all-target"
|
||||||
|
const robolectricPrebuiltLibPattern = "platform-robolectric-%s-prebuilt"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
roboCoverageLibsTag = dependencyTag{name: "roboCoverageLibs"}
|
roboCoverageLibsTag = dependencyTag{name: "roboCoverageLibs"}
|
||||||
roboRuntimesTag = dependencyTag{name: "roboRuntimes"}
|
roboRuntimesTag = dependencyTag{name: "roboRuntimes"}
|
||||||
|
@ -57,6 +59,10 @@ type robolectricProperties struct {
|
||||||
// Number of shards to use when running the tests.
|
// Number of shards to use when running the tests.
|
||||||
Shards *int64
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
type robolectricTest struct {
|
type robolectricTest struct {
|
||||||
|
@ -94,6 +100,12 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
ctx.PropertyErrorf("instrumentation_for", "missing required instrumented module")
|
ctx.PropertyErrorf("instrumentation_for", "missing required instrumented module")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v := String(r.robolectricProperties.Robolectric_prebuilt_version); v != "" {
|
||||||
|
ctx.AddVariationDependencies(nil, libTag, fmt.Sprintf(robolectricPrebuiltLibPattern, v))
|
||||||
|
} else {
|
||||||
|
ctx.AddVariationDependencies(nil, libTag, robolectricCurrentLib)
|
||||||
|
}
|
||||||
|
|
||||||
ctx.AddVariationDependencies(nil, libTag, robolectricDefaultLibs...)
|
ctx.AddVariationDependencies(nil, libTag, robolectricDefaultLibs...)
|
||||||
|
|
||||||
ctx.AddVariationDependencies(nil, roboCoverageLibsTag, r.robolectricProperties.Coverage_libs...)
|
ctx.AddVariationDependencies(nil, roboCoverageLibsTag, r.robolectricProperties.Coverage_libs...)
|
||||||
|
@ -298,7 +310,11 @@ func (r *robolectricTest) writeTestRunner(w io.Writer, module, name string, test
|
||||||
if t := r.robolectricProperties.Test_options.Timeout; t != nil {
|
if t := r.robolectricProperties.Test_options.Timeout; t != nil {
|
||||||
fmt.Fprintln(w, "LOCAL_ROBOTEST_TIMEOUT :=", *t)
|
fmt.Fprintln(w, "LOCAL_ROBOTEST_TIMEOUT :=", *t)
|
||||||
}
|
}
|
||||||
fmt.Fprintln(w, "-include external/robolectric-shadows/run_robotests.mk")
|
if v := String(r.robolectricProperties.Robolectric_prebuilt_version); v != "" {
|
||||||
|
fmt.Fprintf(w, "-include prebuilts/misc/common/robolectric/%s/run_robotests.mk\n", v)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(w, "-include external/robolectric-shadows/run_robotests.mk")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// An android_robolectric_test module compiles tests against the Robolectric framework that can run on the local host
|
// An android_robolectric_test module compiles tests against the Robolectric framework that can run on the local host
|
||||||
|
|
Loading…
Reference in a new issue