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/android/mutator_test.go b/android/mutator_test.go
index 2350fdb..d179f9d 100644
--- a/android/mutator_test.go
+++ b/android/mutator_test.go
@@ -56,7 +56,15 @@
}
func TestMutatorAddMissingDependencies(t *testing.T) {
- config := TestConfig(buildDir, nil)
+ bp := `
+ test {
+ name: "foo",
+ deps_missing_deps: ["regular_missing_dep"],
+ mutator_missing_deps: ["added_missing_dep"],
+ }
+ `
+
+ config := TestConfig(buildDir, nil, bp, nil)
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
ctx := NewTestContext()
@@ -67,21 +75,7 @@
ctx.TopDown("add_missing_dependencies", addMissingDependenciesMutator)
})
- bp := `
- test {
- name: "foo",
- deps_missing_deps: ["regular_missing_dep"],
- mutator_missing_deps: ["added_missing_dep"],
- }
- `
-
- mockFS := map[string][]byte{
- "Android.bp": []byte(bp),
- }
-
- ctx.MockFileSystem(mockFS)
-
- ctx.Register()
+ ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
FailIfErrored(t, errs)
_, errs = ctx.PrepareBuildActions(config)
@@ -139,15 +133,9 @@
}
`
- mockFS := map[string][]byte{
- "Android.bp": []byte(bp),
- }
+ config := TestConfig(buildDir, nil, bp, nil)
- ctx.MockFileSystem(mockFS)
-
- ctx.Register()
-
- config := TestConfig(buildDir, nil)
+ ctx.Register(config)
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
FailIfErrored(t, errs)