diff options
| author | 2019-06-25 11:20:53 -0700 | |
|---|---|---|
| committer | 2019-06-25 11:20:53 -0700 | |
| commit | c1001ec0c53a38c45ea4f621d7ca4366f19e63f2 (patch) | |
| tree | 8e56d88f23b3481fa701a2edd31d87259553bad1 | |
| parent | 50c744e9162bdf6c6d00621e86b11585be517e58 (diff) | |
Create test build dir only once for apex_test.
Test: apex_test.go
Change-Id: Ib96ea4ec5d5ff0d8e8cf4a9eb479099cf2b1977c
| -rw-r--r-- | apex/apex_test.go | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go index 5332f6b2a..2e44db7c7 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -30,9 +30,12 @@ import ( var buildDir string func testApex(t *testing.T, bp string) *android.TestContext { - var config android.Config - config, buildDir = setup(t) - defer teardown(buildDir) + config := android.TestArchConfig(buildDir, nil) + config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current") + config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test") + config.TestProductVariables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"} + config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Q") + config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false) ctx := android.NewTestArchContext() ctx.RegisterModuleType("apex", android.ModuleFactoryAdaptor(apexBundleFactory)) @@ -191,22 +194,15 @@ func testApex(t *testing.T, bp string) *android.TestContext { return ctx } -func setup(t *testing.T) (config android.Config, buildDir string) { - buildDir, err := ioutil.TempDir("", "soong_apex_test") +func setUp() { + var err error + buildDir, err = ioutil.TempDir("", "soong_apex_test") if err != nil { - t.Fatal(err) + panic(err) } - - config = android.TestArchConfig(buildDir, nil) - config.TestProductVariables.DeviceVndkVersion = proptools.StringPtr("current") - config.TestProductVariables.DefaultAppCertificate = proptools.StringPtr("vendor/foo/devkeys/test") - config.TestProductVariables.CertificateOverrides = []string{"myapex_keytest:myapex.certificate.override"} - config.TestProductVariables.Platform_sdk_codename = proptools.StringPtr("Q") - config.TestProductVariables.Platform_sdk_final = proptools.BoolPtr(false) - return } -func teardown(buildDir string) { +func tearDown() { os.RemoveAll(buildDir) } @@ -1288,3 +1284,14 @@ func TestPrebuiltFilenameOverride(t *testing.T) { t.Errorf("installFilename invalid. expected: %q, actual: %q", expected, p.installFilename) } } + +func TestMain(m *testing.M) { + run := func() int { + setUp() + defer tearDown() + + return m.Run() + } + + os.Exit(run()) +} |