Re-enable prebuilt_test

am: 0d614dd222

Change-Id: I544461f21b3e794f728b84c9dd15f9d5c1644428
This commit is contained in:
Colin Cross 2016-10-15 02:05:04 +00:00 committed by android-build-merger
commit 64c42791f1
3 changed files with 41 additions and 6 deletions

View File

@ -82,7 +82,7 @@ bootstrap_go_package {
],
testSrcs: [
"android/paths_test.go",
//"android/prebuilt_test.go",
"android/prebuilt_test.go",
],
}

View File

@ -152,8 +152,10 @@ func saveToConfigFile(config jsonConfigurable, filename string) error {
}
// TestConfig returns a Config object suitable for using for tests
func TestConfig() Config {
return Config{&config{}}
func TestConfig(buildDir string) Config {
return Config{&config{
buildDir: buildDir,
}}
}
// New creates a new Config object. The srcDir argument specifies the path to

View File

@ -15,6 +15,8 @@
package android
import (
"io/ioutil"
"os"
"testing"
"github.com/google/blueprint"
@ -81,9 +83,43 @@ var prebuiltsTests = []struct {
}`,
prebuilt: true,
},
{
name: "prebuilt no file not preferred",
modules: `
source {
name: "bar",
}
prebuilt {
name: "bar",
prefer: false,
}`,
prebuilt: false,
},
{
name: "prebuilt no file preferred",
modules: `
source {
name: "bar",
}
prebuilt {
name: "bar",
prefer: true,
}`,
prebuilt: false,
},
}
func TestPrebuilts(t *testing.T) {
buildDir, err := ioutil.TempDir("", "soong_prebuilt_test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(buildDir)
config := TestConfig(buildDir)
for _, test := range prebuiltsTests {
t.Run(test.name, func(t *testing.T) {
ctx := NewContext()
@ -98,8 +134,6 @@ func TestPrebuilts(t *testing.T) {
` + test.modules),
})
config := TestConfig()
_, errs := ctx.ParseBlueprintsFiles("Blueprints")
fail(t, errs)
_, errs = ctx.PrepareBuildActions(config)
@ -129,7 +163,6 @@ func TestPrebuilts(t *testing.T) {
}
})
}
}
type prebuiltModule struct {