Move filesystem into Config
The filesystem object was available through ModuleContext.Fs(), but
gives too much access to the filesystem without enforicing correct
dependencies. In order to support sandboxing the soong_build
process move the filesystem into the Config. The next change will
make it private.
Bug: 146437378
Test: all Soong tests
Change-Id: I5d3ae9108f120fd335b21efd612aefa078378813
diff --git a/cc/genrule_test.go b/cc/genrule_test.go
index 785e3e1..d38cf27 100644
--- a/cc/genrule_test.go
+++ b/cc/genrule_test.go
@@ -21,31 +21,20 @@
"android/soong/android"
)
-func testGenruleContext(config android.Config, bp string,
- fs map[string][]byte) *android.TestContext {
-
+func testGenruleContext(config android.Config) *android.TestContext {
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("cc_genrule", genRuleFactory)
- ctx.Register()
-
- mockFS := map[string][]byte{
- "Android.bp": []byte(bp),
- "tool": nil,
- "foo": nil,
- "bar": nil,
- }
-
- for k, v := range fs {
- mockFS[k] = v
- }
-
- ctx.MockFileSystem(mockFS)
+ ctx.Register(config)
return ctx
}
func TestArchGenruleCmd(t *testing.T) {
- config := android.TestArchConfig(buildDir, nil)
+ fs := map[string][]byte{
+ "tool": nil,
+ "foo": nil,
+ "bar": nil,
+ }
bp := `
cc_genrule {
name: "gen",
@@ -63,8 +52,9 @@
},
}
`
+ config := android.TestArchConfig(buildDir, nil, bp, fs)
- ctx := testGenruleContext(config, bp, nil)
+ ctx := testGenruleContext(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
if errs == nil {