diff options
Diffstat (limited to 'sh/sh_binary_test.go')
-rw-r--r-- | sh/sh_binary_test.go | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/sh/sh_binary_test.go b/sh/sh_binary_test.go index f48f7fb29..7a24168e5 100644 --- a/sh/sh_binary_test.go +++ b/sh/sh_binary_test.go @@ -37,28 +37,32 @@ func TestMain(m *testing.M) { os.Exit(run()) } -func testShBinary(t *testing.T, bp string) (*android.TestContext, android.Config) { - fs := map[string][]byte{ +var shFixtureFactory = android.NewFixtureFactory( + &buildDir, + cc.PrepareForTestWithCcBuildComponents, + PrepareForTestWithShBuildComponents, + android.FixtureMergeMockFs(android.MockFS{ "test.sh": nil, "testdata/data1": nil, "testdata/sub/data2": nil, - } - - config := android.TestArchConfig(buildDir, nil, bp, fs) - - ctx := android.NewTestArchContext(config) - ctx.RegisterModuleType("sh_test", ShTestFactory) - ctx.RegisterModuleType("sh_test_host", ShTestHostFactory) - - cc.RegisterRequiredBuildComponentsForTest(ctx) + }), +) - ctx.Register() - _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) - android.FailIfErrored(t, errs) - _, errs = ctx.PrepareBuildActions(config) - android.FailIfErrored(t, errs) +// testShBinary runs tests using the shFixtureFactory +// +// Do not add any new usages of this, instead use the shFixtureFactory directly as it makes it much +// easier to customize the test behavior. +// +// If it is necessary to customize the behavior of an existing test that uses this then please first +// convert the test to using shFixtureFactory first and then in a following change add the +// appropriate fixture preparers. Keeping the conversion change separate makes it easy to verify +// that it did not change the test behavior unexpectedly. +// +// deprecated +func testShBinary(t *testing.T, bp string) (*android.TestContext, android.Config) { + result := shFixtureFactory.RunTestWithBp(t, bp) - return ctx, config + return result.TestContext, result.Config } func TestShTestSubDir(t *testing.T) { |