Make completion alias assertion order independent
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package commandkit
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"reflect"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
commandmeta "gitea.maximumdirect.net/eric/CommandKit/internal/commandmeta"
|
||||
@@ -67,8 +69,20 @@ func TestCompletionCommandContext(t *testing.T) {
|
||||
if (tc.name == "runnable child" || tc.name == "unmatched child") && (context.command == nil || len(context.command.Arguments) != 1) {
|
||||
t.Fatalf("runnable operand metadata missing: %#v", context.command)
|
||||
}
|
||||
if tc.name == "entered alias" && !reflect.DeepEqual(context.aliases, []commandmeta.FlagAlias{{Source: "--detail", Target: "--verbose"}, {Source: "--silent", Target: "--quiet"}}) {
|
||||
t.Fatalf("canonical aliases=%#v", context.aliases)
|
||||
if tc.name == "entered alias" {
|
||||
actual := slices.Clone(context.aliases)
|
||||
expected := []commandmeta.FlagAlias{{Source: "--detail", Target: "--verbose"}, {Source: "--silent", Target: "--quiet"}}
|
||||
compare := func(a, b commandmeta.FlagAlias) int {
|
||||
if result := cmp.Compare(a.Source, b.Source); result != 0 {
|
||||
return result
|
||||
}
|
||||
return cmp.Compare(a.Target, b.Target)
|
||||
}
|
||||
slices.SortFunc(actual, compare)
|
||||
slices.SortFunc(expected, compare)
|
||||
if !slices.Equal(actual, expected) {
|
||||
t.Fatalf("canonical aliases=%#v, want %#v", actual, expected)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# ReleaseKit v0.9.0 implementation plan
|
||||
|
||||
Status: planned; Stages 1–6 are not started.
|
||||
Status: Stage 1 complete; Stages 2–6 are not started.
|
||||
|
||||
Implement these stages in integer order during one end-to-end sprint. The target
|
||||
audience is the Luna coding agent. Intermediate stages may temporarily leave
|
||||
@@ -56,7 +56,9 @@ new validators, or add a local recovery implementation.
|
||||
|
||||
## Stage 1: Repair the completion assertion's ordering assumption
|
||||
|
||||
**Status:** not started.
|
||||
**Completed.** The alias comparison sorts cloned actual and expected records
|
||||
without changing production behavior. The prescribed 30 repetitions passed
|
||||
offline with Go 1.26.8.
|
||||
|
||||
Edit only the relevant test assertions and standard-library imports in
|
||||
`completion_context_test.go`. Use Go 1.26.8 on `PATH` as described in the
|
||||
|
||||
Reference in New Issue
Block a user