Ensure subtest failures are reported on subtest
A subtest (code inside the func passed to t.Run(...)) are passed their own t *Testing pointer to use to report errors in order to ensure that they are treated as errors of the subtest and not the containing test. This change ensures that the subtests in the following tests use the correct t *Testing. * TestPrebuiltExportDexImplementationJars * TestBootDexJarsFromSourcesAndPrebuilts Bug: 178361284 Test: m nothing Change-Id: I4e8b166051cb6098c89d8e68a450c81a714f7677
This commit is contained in:
parent
254aee4843
commit
89886cbdb0
|
@ -4362,7 +4362,7 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
|
||||||
// Empty transformation.
|
// Empty transformation.
|
||||||
}
|
}
|
||||||
|
|
||||||
checkDexJarBuildPath := func(ctx *android.TestContext, name string) {
|
checkDexJarBuildPath := func(t *testing.T, ctx *android.TestContext, name string) {
|
||||||
// Make sure the import has been given the correct path to the dex jar.
|
// Make sure the import has been given the correct path to the dex jar.
|
||||||
p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.Dependency)
|
p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.Dependency)
|
||||||
dexJarBuildPath := p.DexJarBuildPath()
|
dexJarBuildPath := p.DexJarBuildPath()
|
||||||
|
@ -4371,7 +4371,7 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureNoSourceVariant := func(ctx *android.TestContext) {
|
ensureNoSourceVariant := func(t *testing.T, ctx *android.TestContext) {
|
||||||
// Make sure that an apex variant is not created for the source module.
|
// Make sure that an apex variant is not created for the source module.
|
||||||
if expected, actual := []string{"android_common"}, ctx.ModuleVariantsForTests("libfoo"); !reflect.DeepEqual(expected, actual) {
|
if expected, actual := []string{"android_common"}, ctx.ModuleVariantsForTests("libfoo"); !reflect.DeepEqual(expected, actual) {
|
||||||
t.Errorf("invalid set of variants for %q: expected %q, found %q", "libfoo", expected, actual)
|
t.Errorf("invalid set of variants for %q: expected %q, found %q", "libfoo", expected, actual)
|
||||||
|
@ -4402,7 +4402,7 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
|
||||||
// Make sure that dexpreopt can access dex implementation files from the prebuilt.
|
// Make sure that dexpreopt can access dex implementation files from the prebuilt.
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
|
|
||||||
checkDexJarBuildPath(ctx, "libfoo")
|
checkDexJarBuildPath(t, ctx, "libfoo")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("prebuilt with source preferred", func(t *testing.T) {
|
t.Run("prebuilt with source preferred", func(t *testing.T) {
|
||||||
|
@ -4434,8 +4434,8 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
|
||||||
// Make sure that dexpreopt can access dex implementation files from the prebuilt.
|
// Make sure that dexpreopt can access dex implementation files from the prebuilt.
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
|
|
||||||
checkDexJarBuildPath(ctx, "prebuilt_libfoo")
|
checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
|
||||||
ensureNoSourceVariant(ctx)
|
ensureNoSourceVariant(t, ctx)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("prebuilt preferred with source", func(t *testing.T) {
|
t.Run("prebuilt preferred with source", func(t *testing.T) {
|
||||||
|
@ -4467,8 +4467,8 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) {
|
||||||
// Make sure that dexpreopt can access dex implementation files from the prebuilt.
|
// Make sure that dexpreopt can access dex implementation files from the prebuilt.
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
|
|
||||||
checkDexJarBuildPath(ctx, "prebuilt_libfoo")
|
checkDexJarBuildPath(t, ctx, "prebuilt_libfoo")
|
||||||
ensureNoSourceVariant(ctx)
|
ensureNoSourceVariant(t, ctx)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4477,7 +4477,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
config.BootJars = android.CreateTestConfiguredJarList([]string{"myapex:libfoo"})
|
config.BootJars = android.CreateTestConfiguredJarList([]string{"myapex:libfoo"})
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBootDexJarPath := func(ctx *android.TestContext, bootDexJarPath string) {
|
checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, bootDexJarPath string) {
|
||||||
s := ctx.SingletonForTests("dex_bootjars")
|
s := ctx.SingletonForTests("dex_bootjars")
|
||||||
foundLibfooJar := false
|
foundLibfooJar := false
|
||||||
for _, output := range s.AllOutputs() {
|
for _, output := range s.AllOutputs() {
|
||||||
|
@ -4518,7 +4518,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
`
|
`
|
||||||
|
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
checkBootDexJarPath(ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("prebuilt with source library preferred", func(t *testing.T) {
|
t.Run("prebuilt with source library preferred", func(t *testing.T) {
|
||||||
|
@ -4587,7 +4587,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
`
|
`
|
||||||
|
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
checkBootDexJarPath(ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("prebuilt with source apex preferred", func(t *testing.T) {
|
t.Run("prebuilt with source apex preferred", func(t *testing.T) {
|
||||||
|
@ -4631,7 +4631,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
`
|
`
|
||||||
|
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
checkBootDexJarPath(ctx, ".intermediates/libfoo/android_common_apex10000/aligned/libfoo.jar")
|
checkBootDexJarPath(t, ctx, ".intermediates/libfoo/android_common_apex10000/aligned/libfoo.jar")
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("prebuilt preferred with source apex disabled", func(t *testing.T) {
|
t.Run("prebuilt preferred with source apex disabled", func(t *testing.T) {
|
||||||
|
@ -4677,7 +4677,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
|
||||||
`
|
`
|
||||||
|
|
||||||
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
ctx := testDexpreoptWithApexes(t, bp, "", transform)
|
||||||
checkBootDexJarPath(ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue