Share buildDir for android/soong/android tests
There is no need to create a separate buildDir for each test
file, use TestMain to create a global one for the package.
Test: all soong tests
Change-Id: I435ee7aa88b7e0bb8ccc1ba79f82833a7accf3e9
diff --git a/android/prebuilt_etc_test.go b/android/prebuilt_etc_test.go
index d977c30..0a2c7a4 100644
--- a/android/prebuilt_etc_test.go
+++ b/android/prebuilt_etc_test.go
@@ -15,16 +15,13 @@
package android
import (
- "io/ioutil"
- "os"
"path/filepath"
"reflect"
"testing"
)
func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
- config, buildDir := setUp(t)
- defer tearDown(buildDir)
+ config := TestArchConfig(buildDir, nil)
ctx := NewTestArchContext()
ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory))
ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(PrebuiltEtcHostFactory))
@@ -51,20 +48,6 @@
return ctx, config
}
-func setUp(t *testing.T) (config Config, buildDir string) {
- buildDir, err := ioutil.TempDir("", "soong_prebuilt_etc_test")
- if err != nil {
- t.Fatal(err)
- }
-
- config = TestArchConfig(buildDir, nil)
- return
-}
-
-func tearDown(buildDir string) {
- os.RemoveAll(buildDir)
-}
-
func TestPrebuiltEtcVariants(t *testing.T) {
ctx, _ := testPrebuiltEtc(t, `
prebuilt_etc {