From 0dc4ac41f04d4c31f2253044122a6699363a264d Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Wed, 4 Nov 2026 03:00:58 +0000 Subject: [PATCH] Make completion alias assertion order independent --- completion_context_test.go | 18 ++++++++++++++++-- docs/roadmap/implementation.md | 6 ++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/completion_context_test.go b/completion_context_test.go index ca8157c..576647e 100644 --- a/completion_context_test.go +++ b/completion_context_test.go @@ -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) + } } }) } diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 6839000..e5c5e42 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -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