treewide: parallel tests
All checks were successful
Test / Create distribution (push) Successful in 25s
Test / Hakurei (push) Successful in 44s
Test / Sandbox (push) Successful in 41s
Test / Hakurei (race detector) (push) Successful in 44s
Test / Sandbox (race detector) (push) Successful in 41s
Test / Hpkg (push) Successful in 41s
Test / Flake checks (push) Successful in 1m24s
All checks were successful
Test / Create distribution (push) Successful in 25s
Test / Hakurei (push) Successful in 44s
Test / Sandbox (push) Successful in 41s
Test / Hakurei (race detector) (push) Successful in 44s
Test / Sandbox (race detector) (push) Successful in 41s
Test / Hpkg (push) Successful in 41s
Test / Flake checks (push) Successful in 1m24s
Most tests already had no global state, however parallel was never enabled. This change enables it for all applicable tests. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func TestConfigValidate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
config *hst.Config
|
||||
@@ -45,6 +47,7 @@ func TestConfigValidate(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if err := tc.config.Validate(); !reflect.DeepEqual(err, tc.wantErr) {
|
||||
t.Errorf("Validate: error = %#v, want %#v", err, tc.wantErr)
|
||||
}
|
||||
@@ -53,6 +56,8 @@ func TestConfigValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExtraPermConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
config *hst.ExtraPermConfig
|
||||
@@ -72,6 +77,7 @@ func TestExtraPermConfig(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := tc.config.String(); got != tc.want {
|
||||
t.Errorf("String: %q, want %q", got, tc.want)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
)
|
||||
|
||||
func TestBadInterfaceError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
err error
|
||||
@@ -23,6 +25,7 @@ func TestBadInterfaceError(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if gotError := tc.err.Error(); gotError != tc.want {
|
||||
t.Errorf("Error: %s, want %s", gotError, tc.want)
|
||||
}
|
||||
@@ -36,6 +39,8 @@ func TestBadInterfaceError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBusConfigInterfaces(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
c *hst.BusConfig
|
||||
@@ -63,6 +68,7 @@ func TestBusConfigInterfaces(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
var got []string
|
||||
if tc.cutoff > 0 {
|
||||
var i int
|
||||
@@ -86,6 +92,8 @@ func TestBusConfigInterfaces(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBusConfigCheckInterfaces(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
c *hst.BusConfig
|
||||
@@ -101,6 +109,7 @@ func TestBusConfigCheckInterfaces(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if err := tc.c.CheckInterfaces(tc.name); !reflect.DeepEqual(err, tc.err) {
|
||||
t.Errorf("CheckInterfaces: error = %#v, want %#v", err, tc.err)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import (
|
||||
)
|
||||
|
||||
func TestEnablementString(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
flags hst.Enablement
|
||||
want string
|
||||
@@ -38,6 +40,7 @@ func TestEnablementString(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.want, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := tc.flags.String(); got != tc.want {
|
||||
t.Errorf("String: %q, want %q", got, tc.want)
|
||||
}
|
||||
@@ -46,6 +49,8 @@ func TestEnablementString(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEnablements(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
e *hst.Enablements
|
||||
@@ -63,7 +68,10 @@ func TestEnablements(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("marshal", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got, err := json.Marshal(tc.e); err != nil {
|
||||
t.Fatalf("Marshal: error = %v", err)
|
||||
} else if string(got) != tc.data {
|
||||
@@ -81,6 +89,8 @@ func TestEnablements(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("unmarshal", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
{
|
||||
got := new(hst.Enablements)
|
||||
if err := json.Unmarshal([]byte(tc.data), &got); err != nil {
|
||||
@@ -116,6 +126,8 @@ func TestEnablements(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("unwrap", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("nil", func(t *testing.T) {
|
||||
if got := (*hst.Enablements)(nil).Unwrap(); got != 0 {
|
||||
t.Errorf("Unwrap: %v", got)
|
||||
@@ -130,6 +142,8 @@ func TestEnablements(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("passthrough", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if _, err := (*hst.Enablements)(nil).MarshalJSON(); !errors.Is(err, syscall.EINVAL) {
|
||||
t.Errorf("MarshalJSON: error = %v", err)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ import (
|
||||
)
|
||||
|
||||
func TestFilesystemConfigJSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
want hst.FilesystemConfigJSON
|
||||
@@ -86,7 +88,10 @@ func TestFilesystemConfigJSON(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("marshal", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
wantErr := tc.wantErr
|
||||
if errors.As(wantErr, new(hst.FSTypeError)) {
|
||||
// for unsupported implementation tc
|
||||
@@ -122,6 +127,7 @@ func TestFilesystemConfigJSON(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("unmarshal", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if tc.data == "\x00" && tc.sData == "\x00" {
|
||||
if errors.As(tc.wantErr, new(hst.FSImplError)) {
|
||||
// this error is only returned on marshal
|
||||
@@ -163,6 +169,8 @@ func TestFilesystemConfigJSON(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if got := (*hst.FilesystemConfigJSON).Valid(nil); got {
|
||||
t.Errorf("Valid: %v, want false", got)
|
||||
}
|
||||
@@ -177,6 +185,7 @@ func TestFilesystemConfigJSON(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("passthrough", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if err := new(hst.FilesystemConfigJSON).UnmarshalJSON(make([]byte, 0)); err == nil {
|
||||
t.Errorf("UnmarshalJSON: error = %v", err)
|
||||
}
|
||||
@@ -184,7 +193,10 @@ func TestFilesystemConfigJSON(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFSErrors(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("type", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
want := `invalid filesystem type "cat"`
|
||||
if got := hst.FSTypeError("cat").Error(); got != want {
|
||||
t.Errorf("Error: %q, want %q", got, want)
|
||||
@@ -192,6 +204,8 @@ func TestFSErrors(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("impl", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
val hst.FilesystemConfig
|
||||
@@ -205,6 +219,7 @@ func TestFSErrors(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := hst.FSImplError{Value: tc.val}
|
||||
if got := err.Error(); got != tc.want {
|
||||
t.Errorf("Error: %q, want %q", got, tc.want)
|
||||
@@ -242,13 +257,17 @@ type fsTestCase struct {
|
||||
func checkFs(t *testing.T, testCases []fsTestCase) {
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("valid", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := tc.fs.Valid(); got != tc.valid {
|
||||
t.Errorf("Valid: %v, want %v", got, tc.valid)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("ops", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ops := new(container.Ops)
|
||||
tc.fs.Apply(&hst.ApplyState{AutoEtcPrefix: ":3", Ops: opsAdapter{ops}})
|
||||
if !reflect.DeepEqual(ops, &tc.ops) {
|
||||
@@ -265,18 +284,21 @@ func checkFs(t *testing.T, testCases []fsTestCase) {
|
||||
})
|
||||
|
||||
t.Run("path", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := tc.fs.Path(); !reflect.DeepEqual(got, tc.path) {
|
||||
t.Errorf("Target: %q, want %q", got, tc.path)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("host", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := tc.fs.Host(); !reflect.DeepEqual(got, tc.host) {
|
||||
t.Errorf("Host: %q, want %q", got, tc.host)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("string", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if tc.str == "\x00" {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func TestFSBind(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
checkFs(t, []fsTestCase{
|
||||
{"nil", (*hst.FSBind)(nil), false, nil, nil, nil, "<invalid>"},
|
||||
{"ensure optional", &hst.FSBind{Source: m("/"), Ensure: true, Optional: true},
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func TestFSEphemeral(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
checkFs(t, []fsTestCase{
|
||||
{"nil", (*hst.FSEphemeral)(nil), false, nil, nil, nil, "<invalid>"},
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
)
|
||||
|
||||
func TestFSLink(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
checkFs(t, []fsTestCase{
|
||||
{"nil", (*hst.FSLink)(nil), false, nil, nil, nil, "<invalid>"},
|
||||
{"zero", new(hst.FSLink), false, nil, nil, nil, "<invalid>"},
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func TestFSOverlay(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
checkFs(t, []fsTestCase{
|
||||
{"nil", (*hst.FSOverlay)(nil), false, nil, nil, nil, "<invalid>"},
|
||||
{"nil lower", &hst.FSOverlay{Target: m("/etc"), Lower: []*check.Absolute{nil}}, false, nil, nil, nil, "<invalid>"},
|
||||
|
||||
@@ -14,6 +14,8 @@ import (
|
||||
)
|
||||
|
||||
func TestAppError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
err error
|
||||
@@ -58,13 +60,17 @@ func TestAppError(t *testing.T) {
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("error", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := tc.err.Error(); got != tc.s {
|
||||
t.Errorf("Error: %s, want %s", got, tc.s)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("message", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
gotMessage, gotMessageOk := message.GetMessage(tc.err)
|
||||
if want := tc.message != "\x00"; gotMessageOk != want {
|
||||
t.Errorf("GetMessage: ok = %v, want %v", gotMessage, want)
|
||||
@@ -78,6 +84,7 @@ func TestAppError(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("is", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !errors.Is(tc.err, tc.is) {
|
||||
t.Errorf("Is: unexpected false for %v", tc.is)
|
||||
}
|
||||
@@ -90,6 +97,8 @@ func TestAppError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTemplate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const want = `{
|
||||
"id": "org.chromium.Chromium",
|
||||
"enablements": {
|
||||
|
||||
Reference in New Issue
Block a user