summaryrefslogtreecommitdiff
path: root/sdk/bp_test.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2025-02-05 16:39:18 -0800
committer Colin Cross <ccross@android.com> 2025-02-06 23:43:51 +0000
commitaba8cd956a1f0cca137f6ab02b9791aac9435efd (patch)
treec5bd44db386b2f00d7e97af41999677e65f22e1b /sdk/bp_test.go
parente4762bac43777e5a3f0472ed37342c59bf29d626 (diff)
Add t.Parallel() to SDK tests
Reduces time to run go test ./sdk from 44 seconds to 22.5 seconds. Requires moving snapshotTestCustomizations from a map to a struct with individual fields to avoid concurrent map accesses between subtests. Test: go test ./sdk Change-Id: Id6f451ba9cbace8bc7ea915033a795456b85cf3f
Diffstat (limited to 'sdk/bp_test.go')
-rw-r--r--sdk/bp_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/sdk/bp_test.go b/sdk/bp_test.go
index c620ac2b8..d3eaafeba 100644
--- a/sdk/bp_test.go
+++ b/sdk/bp_test.go
@@ -73,6 +73,7 @@ func checkPropertySetFixture(t *testing.T, val interface{}, hasTags bool) {
}
func TestAddPropertySimple(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
for name, val := range map[string]interface{}{
"x": "taxi",
@@ -91,14 +92,17 @@ func TestAddPropertySimple(t *testing.T) {
}
func TestAddPropertySubset(t *testing.T) {
+ t.Parallel()
getFixtureMap := map[string]func() interface{}{
"property set": propertySetFixture,
"property struct": propertyStructFixture,
}
t.Run("add new subset", func(t *testing.T) {
+ t.Parallel()
for name, getFixture := range getFixtureMap {
t.Run(name, func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
set.AddProperty("new", getFixture())
checkPropertySetFixture(t, set, true)
@@ -108,8 +112,10 @@ func TestAddPropertySubset(t *testing.T) {
})
t.Run("merge existing subset", func(t *testing.T) {
+ t.Parallel()
for name, getFixture := range getFixtureMap {
t.Run(name, func(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
subset := set.AddPropertySet("sub")
subset.AddProperty("flag", false)
@@ -123,12 +129,14 @@ func TestAddPropertySubset(t *testing.T) {
})
t.Run("add conflicting subset", func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
android.AssertPanicMessageContains(t, "adding x again should panic", `Property "x" already exists in property set`,
func() { set.AddProperty("x", propertySetFixture()) })
})
t.Run("add non-pointer struct", func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
str := propertyStructFixture().(*propertyStruct)
android.AssertPanicMessageContains(t, "adding a non-pointer struct should panic", "Value is a struct, not a pointer to one:",
@@ -137,6 +145,7 @@ func TestAddPropertySubset(t *testing.T) {
}
func TestAddPropertySetNew(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
subset := set.AddPropertySet("sub")
subset.AddProperty("new", "d^^b")
@@ -144,6 +153,7 @@ func TestAddPropertySetNew(t *testing.T) {
}
func TestAddPropertySetExisting(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
subset := set.AddPropertySet("sub")
subset.AddProperty("new", "d^^b")
@@ -176,6 +186,7 @@ func (t removeFredTransformation) transformPropertySetAfterContents(name string,
}
func TestTransformRemoveProperty(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
set.AddProperty("name", "name")
set.AddProperty("fred", "12")
@@ -188,6 +199,7 @@ func TestTransformRemoveProperty(t *testing.T) {
}
func TestTransformRemovePropertySet(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
set.AddProperty("name", "name")
set.AddPropertySet("fred")