Merge "Add test for building cc_object with Bazel." am: c8c4bf4c98

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1670172

Change-Id: Ifa90e31bddac419981883fd0d05cb1452084474f
This commit is contained in:
Treehugger Robot 2021-04-12 19:49:41 +00:00 committed by Automerger Merge Worker
commit 9b8e4d6b26

View file

@ -15,6 +15,7 @@
package cc
import (
"android/soong/android"
"testing"
)
@ -27,5 +28,28 @@ func TestLinkerScript(t *testing.T) {
linker_script: "foo.lds",
}`)
})
}
func TestCcObjectWithBazel(t *testing.T) {
bp := `
cc_object {
name: "foo",
srcs: ["baz.o"],
bazel_module: { label: "//foo/bar:bar" },
}`
config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
config.BazelContext = android.MockBazelContext{
OutputBaseDir: "outputbase",
LabelToOutputFiles: map[string][]string{
"//foo/bar:bar": []string{"bazel_out.o"}}}
ctx := testCcWithConfig(t, config)
module := ctx.ModuleForTests("foo", "android_arm_armv7-a-neon").Module()
outputFiles, err := module.(android.OutputFileProducer).OutputFiles("")
if err != nil {
t.Errorf("Unexpected error getting cc_object outputfiles %s", err)
}
expectedOutputFiles := []string{"outputbase/execroot/__main__/bazel_out.o"}
android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings())
}