summaryrefslogtreecommitdiff
path: root/xml
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2019-10-02 16:01:35 -0700
committer Colin Cross <ccross@android.com> 2019-10-03 10:07:53 -0700
commitff6c33d885c8a8132728853a8bd2cfd73988b660 (patch)
treee03b3c96fe0dda755920e6f8f9a97e1e5febea10 /xml
parent70dda7e3da7eed09c1c7e0a3ab8b2ed3c9934035 (diff)
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
Diffstat (limited to 'xml')
-rw-r--r--xml/xml_test.go48
1 files changed, 29 insertions, 19 deletions
diff --git a/xml/xml_test.go b/xml/xml_test.go
index ae3e9fe3c..f2a440f9a 100644
--- a/xml/xml_test.go
+++ b/xml/xml_test.go
@@ -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())
}