Replace RelPathString() with ToMakePath()

Add a ToMakePath() method that returns a new path that points out
out/ instead of out/soong/, and replace the
"$(OUT_DIR)/" + path.RelPathString()
pattern with
path.ToMakePath().String()

Bug: 141877526
Test: m checkbuild
Change-Id: I391b9f2ed78c83a58d905d48355ce9b01d610d16
This commit is contained in:
Colin Cross
2019-10-02 16:01:35 -07:00
parent 70dda7e3da
commit ff6c33d885
11 changed files with 88 additions and 70 deletions

View File

@@ -15,15 +15,40 @@
package xml
import (
"android/soong/android"
"io/ioutil"
"os"
"testing"
"android/soong/android"
)
var buildDir string
func setUp() {
var err error
buildDir, err = ioutil.TempDir("", "soong_xml_test")
if err != nil {
panic(err)
}
}
func tearDown() {
os.RemoveAll(buildDir)
}
func TestMain(m *testing.M) {
run := func() int {
setUp()
defer tearDown()
return m.Run()
}
os.Exit(run())
}
func testXml(t *testing.T, bp string) *android.TestContext {
config, buildDir := setup(t)
defer teardown(buildDir)
config := android.TestArchConfig(buildDir, nil)
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("prebuilt_etc", android.ModuleFactoryAdaptor(android.PrebuiltEtcFactory))
ctx.RegisterModuleType("prebuilt_etc_xml", android.ModuleFactoryAdaptor(PrebuiltEtcXmlFactory))
@@ -45,21 +70,6 @@ func testXml(t *testing.T, bp string) *android.TestContext {
return ctx
}
func setup(t *testing.T) (config android.Config, buildDir string) {
buildDir, err := ioutil.TempDir("", "soong_xml_test")
if err != nil {
t.Fatal(err)
}
config = android.TestArchConfig(buildDir, nil)
return
}
func teardown(buildDir string) {
os.RemoveAll(buildDir)
}
func assertEqual(t *testing.T, name, expected, actual string) {
t.Helper()
if expected != actual {
@@ -103,5 +113,5 @@ func TestPrebuiltEtcXml(t *testing.T) {
}
m := ctx.ModuleForTests("foo.xml", "android_arm64_armv8-a").Module().(*prebuiltEtcXml)
assertEqual(t, "installDir", "target/product/test_device/system/etc", m.InstallDirPath().RelPathString())
assertEqual(t, "installDir", buildDir+"/target/product/test_device/system/etc", m.InstallDirPath().String())
}