Automatically call TestingBuildParams.RelativeToTop()
Fixes the few tests that break due to this and which cannot easily be separated into their own changes. Bug: 183650682 Test: m nothing Change-Id: Ia2f31213a1f114a78e66a81d89279ecde9f4c465
This commit is contained in:
parent
b2786a3fdc
commit
e8366da1f6
|
@ -558,7 +558,7 @@ func (p TestingBuildParams) RelativeToTop() TestingBuildParams {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
if p.config.config == nil {
|
if p.config.config == nil {
|
||||||
panic("cannot call RelativeToTop() on a TestingBuildParams previously returned by RelativeToTop()")
|
return p
|
||||||
}
|
}
|
||||||
// Take a copy of the build params and replace any args that contains test specific temporary
|
// Take a copy of the build params and replace any args that contains test specific temporary
|
||||||
// paths with paths relative to the top.
|
// paths with paths relative to the top.
|
||||||
|
@ -670,7 +670,7 @@ func (b baseTestingComponent) newTestingBuildParams(bparams BuildParams) Testing
|
||||||
config: b.config,
|
config: b.config,
|
||||||
BuildParams: bparams,
|
BuildParams: bparams,
|
||||||
RuleParams: b.provider.RuleParamsForTests()[bparams.Rule],
|
RuleParams: b.provider.RuleParamsForTests()[bparams.Rule],
|
||||||
}
|
}.RelativeToTop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuildParams, []string) {
|
func (b baseTestingComponent) maybeBuildParamsFromRule(rule string) (TestingBuildParams, []string) {
|
||||||
|
|
|
@ -5066,7 +5066,7 @@ func TestApexWithApps(t *testing.T) {
|
||||||
}
|
}
|
||||||
// JNI libraries including transitive deps are
|
// JNI libraries including transitive deps are
|
||||||
for _, jni := range []string{"libjni", "libfoo"} {
|
for _, jni := range []string{"libjni", "libfoo"} {
|
||||||
jniOutput := ctx.ModuleForTests(jni, "android_arm64_armv8-a_sdk_shared_apex10000").Module().(*cc.Module).OutputFile()
|
jniOutput := ctx.ModuleForTests(jni, "android_arm64_armv8-a_sdk_shared_apex10000").Module().(*cc.Module).OutputFile().RelativeToPath()
|
||||||
// ... embedded inside APK (jnilibs.zip)
|
// ... embedded inside APK (jnilibs.zip)
|
||||||
ensureListContains(t, appZipRule.Implicits.Strings(), jniOutput.String())
|
ensureListContains(t, appZipRule.Implicits.Strings(), jniOutput.String())
|
||||||
// ... and not directly inside the APEX
|
// ... and not directly inside the APEX
|
||||||
|
|
|
@ -301,13 +301,9 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string
|
||||||
|
|
||||||
func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool, fake bool) {
|
func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string, include bool, fake bool) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
mod, ok := ctx.ModuleForTests(moduleName, variant).Module().(android.OutputFileProducer)
|
mod := ctx.ModuleForTests(moduleName, variant)
|
||||||
if !ok {
|
outputFiles := mod.OutputFiles(t, "")
|
||||||
t.Errorf("%q must have output\n", moduleName)
|
if len(outputFiles) != 1 {
|
||||||
return
|
|
||||||
}
|
|
||||||
outputFiles, err := mod.OutputFiles("")
|
|
||||||
if err != nil || len(outputFiles) != 1 {
|
|
||||||
t.Errorf("%q must have single output\n", moduleName)
|
t.Errorf("%q must have single output\n", moduleName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -333,14 +329,17 @@ func checkSnapshotIncludeExclude(t *testing.T, ctx *android.TestContext, singlet
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
func checkSnapshot(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
||||||
|
t.Helper()
|
||||||
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, false)
|
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
func checkSnapshotExclude(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
||||||
|
t.Helper()
|
||||||
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false, false)
|
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, false, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSnapshotRule(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
func checkSnapshotRule(t *testing.T, ctx *android.TestContext, singleton android.TestingSingleton, moduleName, snapshotFilename, subDir, variant string) {
|
||||||
|
t.Helper()
|
||||||
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, true)
|
checkSnapshotIncludeExclude(t, ctx, singleton, moduleName, snapshotFilename, subDir, variant, true, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2552,7 +2551,7 @@ func parseModuleDeps(text string) (modulesInOrder []android.Path, allDeps map[an
|
||||||
func getOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) {
|
func getOutputPaths(ctx *android.TestContext, variant string, moduleNames []string) (paths android.Paths) {
|
||||||
for _, moduleName := range moduleNames {
|
for _, moduleName := range moduleNames {
|
||||||
module := ctx.ModuleForTests(moduleName, variant).Module().(*Module)
|
module := ctx.ModuleForTests(moduleName, variant).Module().(*Module)
|
||||||
output := module.outputFile.Path()
|
output := module.outputFile.Path().RelativeToTop()
|
||||||
paths = append(paths, output)
|
paths = append(paths, output)
|
||||||
}
|
}
|
||||||
return paths
|
return paths
|
||||||
|
@ -2583,7 +2582,8 @@ func TestStaticLibDepReordering(t *testing.T) {
|
||||||
|
|
||||||
variant := "android_arm64_armv8-a_static"
|
variant := "android_arm64_armv8-a_static"
|
||||||
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
||||||
actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).TransitiveStaticLibrariesForOrdering.ToList()
|
actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).
|
||||||
|
TransitiveStaticLibrariesForOrdering.ToList().RelativeToTop()
|
||||||
expected := getOutputPaths(ctx, variant, []string{"a", "c", "b", "d"})
|
expected := getOutputPaths(ctx, variant, []string{"a", "c", "b", "d"})
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
if !reflect.DeepEqual(actual, expected) {
|
||||||
|
@ -2617,7 +2617,8 @@ func TestStaticLibDepReorderingWithShared(t *testing.T) {
|
||||||
|
|
||||||
variant := "android_arm64_armv8-a_static"
|
variant := "android_arm64_armv8-a_static"
|
||||||
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
moduleA := ctx.ModuleForTests("a", variant).Module().(*Module)
|
||||||
actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).TransitiveStaticLibrariesForOrdering.ToList()
|
actual := ctx.ModuleProvider(moduleA, StaticLibraryInfoProvider).(StaticLibraryInfo).
|
||||||
|
TransitiveStaticLibrariesForOrdering.ToList().RelativeToTop()
|
||||||
expected := getOutputPaths(ctx, variant, []string{"a", "c", "b"})
|
expected := getOutputPaths(ctx, variant, []string{"a", "c", "b"})
|
||||||
|
|
||||||
if !reflect.DeepEqual(actual, expected) {
|
if !reflect.DeepEqual(actual, expected) {
|
||||||
|
|
|
@ -36,8 +36,10 @@ func TestGen(t *testing.T) {
|
||||||
aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("aidl")
|
aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("aidl")
|
||||||
libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Module().(*Module)
|
libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Module().(*Module)
|
||||||
|
|
||||||
if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.Local.CommonFlags) {
|
expected := "-I" + filepath.Dir(aidl.Output.String())
|
||||||
t.Errorf("missing aidl includes in global flags")
|
actual := android.StringsRelativeToTop(ctx.Config(), libfoo.flags.Local.CommonFlags)
|
||||||
|
if !inList(expected, actual) {
|
||||||
|
t.Errorf("missing aidl includes in global flags, expected %q, actual %q", expected, actual)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -61,7 +63,7 @@ func TestGen(t *testing.T) {
|
||||||
aidlManifest := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Output("aidl.sbox.textproto")
|
aidlManifest := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Output("aidl.sbox.textproto")
|
||||||
libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Module().(*Module)
|
libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Module().(*Module)
|
||||||
|
|
||||||
if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.Local.CommonFlags) {
|
if !inList("-I"+filepath.Dir(aidl.Output.String()), android.StringsRelativeToTop(ctx.Config(), libfoo.flags.Local.CommonFlags)) {
|
||||||
t.Errorf("missing aidl includes in global flags")
|
t.Errorf("missing aidl includes in global flags")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
@ -302,8 +301,7 @@ func TestPrebuiltSymlinkedHostBinary(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
fooRule := ctx.ModuleForTests("foo", "linux_glibc_x86_64").Rule("Symlink")
|
fooRule := ctx.ModuleForTests("foo", "linux_glibc_x86_64").Rule("Symlink")
|
||||||
assertString(t, fooRule.Output.String(),
|
assertString(t, fooRule.Output.String(), "out/soong/.intermediates/foo/linux_glibc_x86_64/foo")
|
||||||
filepath.Join(buildDir, ".intermediates/foo/linux_glibc_x86_64/foo"))
|
|
||||||
assertString(t, fooRule.Args["fromPath"], "$$PWD/linux_glibc_x86_64/bin/foo")
|
assertString(t, fooRule.Args["fromPath"], "$$PWD/linux_glibc_x86_64/bin/foo")
|
||||||
|
|
||||||
var libfooDep android.Path
|
var libfooDep android.Path
|
||||||
|
@ -313,8 +311,7 @@ func TestPrebuiltSymlinkedHostBinary(t *testing.T) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertString(t, libfooDep.String(),
|
assertString(t, libfooDep.String(), "out/soong/.intermediates/libfoo/linux_glibc_x86_64_shared/libfoo.so")
|
||||||
filepath.Join(buildDir, ".intermediates/libfoo/linux_glibc_x86_64_shared/libfoo.so"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuiltLibrarySanitized(t *testing.T) {
|
func TestPrebuiltLibrarySanitized(t *testing.T) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ func TestProto(t *testing.T) {
|
||||||
t.Errorf("expected %q in %q", w, cmd)
|
t.Errorf("expected %q in %q", w, cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
foobarPath := foobar.Module().(android.HostToolProvider).HostToolPath().String()
|
foobarPath := foobar.Module().(android.HostToolProvider).HostToolPath().RelativeToPath().String()
|
||||||
|
|
||||||
if w := "--plugin=protoc-gen-foobar=" + foobarPath; !strings.Contains(cmd, w) {
|
if w := "--plugin=protoc-gen-foobar=" + foobarPath; !strings.Contains(cmd, w) {
|
||||||
t.Errorf("expected %q in %q", w, cmd)
|
t.Errorf("expected %q in %q", w, cmd)
|
||||||
|
|
|
@ -66,6 +66,7 @@ func TestSdkMutator(t *testing.T) {
|
||||||
} else {
|
} else {
|
||||||
toFile = m.outputFile.Path()
|
toFile = m.outputFile.Path()
|
||||||
}
|
}
|
||||||
|
toFile = toFile.RelativeToTop()
|
||||||
|
|
||||||
rule := from.Description("link")
|
rule := from.Description("link")
|
||||||
for _, dep := range rule.Implicits {
|
for _, dep := range rule.Implicits {
|
||||||
|
|
|
@ -1670,7 +1670,7 @@ func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
|
||||||
|
|
||||||
// The bar library should depend on the stubs jar.
|
// The bar library should depend on the stubs jar.
|
||||||
barLibrary := result.ModuleForTests("bar", "android_common").Rule("javac")
|
barLibrary := result.ModuleForTests("bar", "android_common").Rule("javac")
|
||||||
if expected, actual := `^-classpath .*:/[^:]*/turbine-combined/foo\.stubs\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
if expected, actual := `^-classpath .*:out/soong/[^:]*/turbine-combined/foo\.stubs\.jar$`, barLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
||||||
t.Errorf("expected %q, found %#q", expected, actual)
|
t.Errorf("expected %q, found %#q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1973,7 +1973,7 @@ func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) {
|
||||||
`)
|
`)
|
||||||
// The baz library should depend on the system stubs jar.
|
// The baz library should depend on the system stubs jar.
|
||||||
bazLibrary := result.ModuleForTests("baz", "android_common").Rule("javac")
|
bazLibrary := result.ModuleForTests("baz", "android_common").Rule("javac")
|
||||||
if expected, actual := `^-classpath .*:/[^:]*/turbine-combined/foo\.stubs.system\.jar$`, bazLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
if expected, actual := `^-classpath .*:out/soong/[^:]*/turbine-combined/foo\.stubs.system\.jar$`, bazLibrary.Args["classpath"]; !regexp.MustCompile(expected).MatchString(actual) {
|
||||||
t.Errorf("expected %q, found %#q", expected, actual)
|
t.Errorf("expected %q, found %#q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue