aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-10-14 15:38:43 -0700
committerColin Cross <ccross@android.com>2016-10-14 17:07:49 -0700
commit0d614dd222db217a4ed34c090628349bb1e531dc (patch)
treee48ab8d9e9cbc3a93f62f90f3f3a69485aac6374 /android
parent6efa287aea45935e6025f2a761dcdecae6c12835 (diff)
downloadbuild_soong-0d614dd222db217a4ed34c090628349bb1e531dc.tar.gz
build_soong-0d614dd222db217a4ed34c090628349bb1e531dc.tar.bz2
build_soong-0d614dd222db217a4ed34c090628349bb1e531dc.zip
Re-enable prebuilt_test
Use a temporary directory as the build directory during tests so files don't get written to the source tree. Also add a few more tests for prebuilts with no file specified. Bug: 31800129 Test: m -j, make sure .soong.environment is not written to the source tree Change-Id: I623bc114b2ff534c8df9fb3ce273e804711f8f05
Diffstat (limited to 'android')
-rw-r--r--android/config.go6
-rw-r--r--android/prebuilt_test.go39
2 files changed, 40 insertions, 5 deletions
diff --git a/android/config.go b/android/config.go
index 1d3fba21..483ec911 100644
--- a/android/config.go
+++ b/android/config.go
@@ -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
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go
index 92d64817..311f821a 100644
--- a/android/prebuilt_test.go
+++ b/android/prebuilt_test.go
@@ -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 {