diff options
author | 2024-10-10 22:32:21 +0000 | |
---|---|---|
committer | 2024-10-10 22:32:21 +0000 | |
commit | 004074db579a9e1abf07fe4c45f35d4d5247cac0 (patch) | |
tree | d92460b53feb6abc37aa85cf755dc35631208937 /android/mutator_test.go | |
parent | fef73af257e936d9b6345ce30ad528c28bbccb98 (diff) | |
parent | 8a9628098bbed62f3af13021b434238308adc7c1 (diff) |
Merge changes from topic "remove-non-parallel-mutator" into main
* changes:
Remove MutatorHandle.Parallel()
Fix TestFinalDepsPhase for parallel mutator
Diffstat (limited to 'android/mutator_test.go')
-rw-r--r-- | android/mutator_test.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/android/mutator_test.go b/android/mutator_test.go index 33fca9e8b..1d5f89042 100644 --- a/android/mutator_test.go +++ b/android/mutator_test.go @@ -17,6 +17,8 @@ package android import ( "fmt" "strings" + "sync" + "sync/atomic" "testing" "github.com/google/blueprint" @@ -220,7 +222,7 @@ func TestFinalDepsPhase(t *testing.T) { } ` - finalGot := map[string]int{} + finalGot := sync.Map{} GroupFixturePreparers( FixtureRegisterWithContext(func(ctx RegistrationContext) { @@ -251,9 +253,11 @@ func TestFinalDepsPhase(t *testing.T) { } }) ctx.BottomUp("final", func(ctx BottomUpMutatorContext) { - finalGot[ctx.Module().String()] += 1 + counter, _ := finalGot.LoadOrStore(ctx.Module().String(), &atomic.Int64{}) + counter.(*atomic.Int64).Add(1) ctx.VisitDirectDeps(func(mod Module) { - finalGot[fmt.Sprintf("%s -> %s", ctx.Module().String(), mod)] += 1 + counter, _ := finalGot.LoadOrStore(fmt.Sprintf("%s -> %s", ctx.Module().String(), mod), &atomic.Int64{}) + counter.(*atomic.Int64).Add(1) }) }) }) @@ -276,7 +280,13 @@ func TestFinalDepsPhase(t *testing.T) { "foo{variant:b} -> common_dep_2{variant:a}": 1, } - AssertDeepEquals(t, "final", finalWant, finalGot) + finalGotMap := make(map[string]int) + finalGot.Range(func(k, v any) bool { + finalGotMap[k.(string)] = int(v.(*atomic.Int64).Load()) + return true + }) + + AssertDeepEquals(t, "final", finalWant, finalGotMap) } func TestTransitionMutatorInFinalDeps(t *testing.T) { |