diff options
author | 2021-03-30 22:45:21 +0100 | |
---|---|---|
committer | 2021-03-30 22:45:21 +0100 | |
commit | 9e0c3f9993cb9545f6bd5fe22e8046564f771176 (patch) | |
tree | 1067682e8e8003f27eb6480b423ca34e24f2402c /rust/clippy_test.go | |
parent | dd3797b44eb9065d77069e51d2231385958897ee (diff) |
Convert remaining rust tests to use test fixtures
Removes now unused CreateTestContext and stops exporting the
RegisterRequiredBuildComponentsForTest() method as it is only used
locally.
Bug: 181070625
Test: m nothing
Change-Id: Ia2fd3e090f975ee4c807da2c6c162ef3cf7ac446
Diffstat (limited to 'rust/clippy_test.go')
-rw-r--r-- | rust/clippy_test.go | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/rust/clippy_test.go b/rust/clippy_test.go index e90564f63..bd3bfb151 100644 --- a/rust/clippy_test.go +++ b/rust/clippy_test.go @@ -18,7 +18,6 @@ import ( "testing" "android/soong/android" - "android/soong/cc" ) func TestClippy(t *testing.T) { @@ -45,15 +44,6 @@ func TestClippy(t *testing.T) { clippy_lints: "none", }` - bp = bp + GatherRequiredDepsForTest() - bp = bp + cc.GatherRequiredDepsForTest(android.NoOsType) - - fs := map[string][]byte{ - // Reuse the same blueprint file for subdirectories. - "external/Android.bp": []byte(bp), - "hardware/Android.bp": []byte(bp), - } - var clippyLintTests = []struct { modulePath string fooFlags string @@ -66,29 +56,22 @@ func TestClippy(t *testing.T) { for _, tc := range clippyLintTests { t.Run("path="+tc.modulePath, func(t *testing.T) { - config := android.TestArchConfig(t.TempDir(), nil, bp, fs) - ctx := CreateTestContext(config) - ctx.Register() - _, errs := ctx.ParseFileList(".", []string{tc.modulePath + "Android.bp"}) - android.FailIfErrored(t, errs) - _, errs = ctx.PrepareBuildActions(config) - android.FailIfErrored(t, errs) + result := android.GroupFixturePreparers( + prepareForRustTest, + // Test with the blueprint file in different directories. + android.FixtureAddTextFile(tc.modulePath+"Android.bp", bp), + ).RunTest(t) - r := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").MaybeRule("clippy") - if r.Args["clippyFlags"] != tc.fooFlags { - t.Errorf("Incorrect flags for libfoo: %q, want %q", r.Args["clippyFlags"], tc.fooFlags) - } + r := result.ModuleForTests("libfoo", "android_arm64_armv8-a_dylib").MaybeRule("clippy") + android.AssertStringEquals(t, "libfoo flags", tc.fooFlags, r.Args["clippyFlags"]) - r = ctx.ModuleForTests("libbar", "android_arm64_armv8-a_dylib").MaybeRule("clippy") - if r.Args["clippyFlags"] != "${config.ClippyDefaultLints}" { - t.Errorf("Incorrect flags for libbar: %q, want %q", r.Args["clippyFlags"], "${config.ClippyDefaultLints}") - } + r = result.ModuleForTests("libbar", "android_arm64_armv8-a_dylib").MaybeRule("clippy") + android.AssertStringEquals(t, "libbar flags", "${config.ClippyDefaultLints}", r.Args["clippyFlags"]) - r = ctx.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").MaybeRule("clippy") + r = result.ModuleForTests("libfoobar", "android_arm64_armv8-a_dylib").MaybeRule("clippy") if r.Rule != nil { t.Errorf("libfoobar is setup to use clippy when explicitly disabled: clippyFlags=%q", r.Args["clippyFlags"]) } - }) } } |