aboutsummaryrefslogtreecommitdiffstats
path: root/cc/test_data_test.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2017-03-16 16:50:10 -0700
committerColin Cross <ccross@android.com>2017-03-16 16:50:10 -0700
commit795c377e1450ad8e88deaaa5365ff1cc90c9f922 (patch)
tree08c3c008b105b615ee3bc03f0ccb1c7af1b7dc4f /cc/test_data_test.go
parent4c48f724e1b339128447ab1dafd656a9557557f5 (diff)
downloadbuild_soong-795c377e1450ad8e88deaaa5365ff1cc90c9f922.tar.gz
build_soong-795c377e1450ad8e88deaaa5365ff1cc90c9f922.tar.bz2
build_soong-795c377e1450ad8e88deaaa5365ff1cc90c9f922.zip
Use a minimal set of mutators, module types, and singletons for tests
Calling android.NewContext() in tests results in a context that contains all the mutators, module types, and singletons, which causes unexpected interactions in unit tests. Create an empty context instead, and add in only the necessary mutators, module types, and singletons. Bug: 36366816 Test: soong tests Change-Id: Ic61262c37e3436b3ad4ccaca18b737021c304be6
Diffstat (limited to 'cc/test_data_test.go')
-rw-r--r--cc/test_data_test.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/cc/test_data_test.go b/cc/test_data_test.go
index e3b1214f..9b5a85a7 100644
--- a/cc/test_data_test.go
+++ b/cc/test_data_test.go
@@ -22,6 +22,8 @@ import (
"testing"
"android/soong/android"
+ "android/soong/genrule"
+
"github.com/google/blueprint"
)
@@ -121,13 +123,15 @@ func TestDataTests(t *testing.T) {
for _, test := range testDataTests {
t.Run(test.name, func(t *testing.T) {
- ctx := android.NewContext()
+ ctx := blueprint.NewContext()
+ android.RegisterTestMutators(ctx)
ctx.MockFileSystem(map[string][]byte{
"Blueprints": []byte(`subdirs = ["dir"]`),
"dir/Blueprints": []byte(test.modules),
"dir/baz": nil,
"dir/bar/baz": nil,
})
+ ctx.RegisterModuleType("filegroup", genrule.FileGroupFactory)
ctx.RegisterModuleType("test", newTest)
_, errs := ctx.ParseBlueprintsFiles("Blueprints")