Make completion alias assertion order independent
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package commandkit
|
package commandkit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
commandmeta "gitea.maximumdirect.net/eric/CommandKit/internal/commandmeta"
|
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) {
|
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)
|
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"}}) {
|
if tc.name == "entered alias" {
|
||||||
t.Fatalf("canonical aliases=%#v", context.aliases)
|
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
|
# 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
|
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
|
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
|
## 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
|
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
|
`completion_context_test.go`. Use Go 1.26.8 on `PATH` as described in the
|
||||||
|
|||||||
Reference in New Issue
Block a user