aboutsummaryrefslogtreecommitdiffhomepage
path: root/command
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-10-13 04:38:48 +0900
committerOphestra <cat@gensokyo.uk>2025-10-13 04:38:48 +0900
commit7638a44fa613f23434318bdf136723aa010e8638 (patch)
tree7b5270ed4e9b6d7f1ee0f28c58d8077aa1d18005 /command
parenta14b6535a66cb7ac0fc4827f767ffaee0ce04b57 (diff)
treewide: parallel tests
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>
Diffstat (limited to 'command')
-rw-r--r--command/builder_test.go1
-rw-r--r--command/parse_test.go3
-rw-r--r--command/unreachable_test.go6
3 files changed, 10 insertions, 0 deletions
diff --git a/command/builder_test.go b/command/builder_test.go
index 95231841..7b9a1701 100644
--- a/command/builder_test.go
+++ b/command/builder_test.go
@@ -7,6 +7,7 @@ import (
)
func TestBuild(t *testing.T) {
+ t.Parallel()
c := command.New(nil, nil, "test", nil)
stubHandler := func([]string) error { panic("unreachable") }
diff --git a/command/parse_test.go b/command/parse_test.go
index ce013f20..c2956c6f 100644
--- a/command/parse_test.go
+++ b/command/parse_test.go
@@ -14,6 +14,8 @@ import (
)
func TestParse(t *testing.T) {
+ t.Parallel()
+
testCases := []struct {
name string
buildTree func(wout, wlog io.Writer) command.Command
@@ -251,6 +253,7 @@ Commands:
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
wout, wlog := new(bytes.Buffer), new(bytes.Buffer)
c := tc.buildTree(wout, wlog)
diff --git a/command/unreachable_test.go b/command/unreachable_test.go
index 71408189..9e8c19c9 100644
--- a/command/unreachable_test.go
+++ b/command/unreachable_test.go
@@ -6,15 +6,19 @@ import (
)
func TestParseUnreachable(t *testing.T) {
+ t.Parallel()
+
// top level bypasses name matching and recursive calls to Parse
// returns when encountering zero-length args
t.Run("zero-length args", func(t *testing.T) {
+ t.Parallel()
defer checkRecover(t, "Parse", "attempted to parse with zero length args")
_ = newNode(panicWriter{}, nil, " ", " ").Parse(nil)
})
// top level must not have siblings
t.Run("toplevel siblings", func(t *testing.T) {
+ t.Parallel()
defer checkRecover(t, "Parse", "invalid toplevel state")
n := newNode(panicWriter{}, nil, " ", "")
n.append(newNode(panicWriter{}, nil, " ", " "))
@@ -23,6 +27,7 @@ func TestParseUnreachable(t *testing.T) {
// a node with descendents must not have a direct handler
t.Run("sub handle conflict", func(t *testing.T) {
+ t.Parallel()
defer checkRecover(t, "Parse", "invalid subcommand tree state")
n := newNode(panicWriter{}, nil, " ", " ")
n.adopt(newNode(panicWriter{}, nil, " ", " "))
@@ -32,6 +37,7 @@ func TestParseUnreachable(t *testing.T) {
// this would only happen if a node was matched twice
t.Run("parsed flag set", func(t *testing.T) {
+ t.Parallel()
defer checkRecover(t, "Parse", "invalid set state")
n := newNode(panicWriter{}, nil, " ", "")
set := flag.NewFlagSet("parsed", flag.ContinueOnError)