The nestif extraction in712388dpulled --provider handling out of parseModelRest into a helper that took modelParts by pointer and appended every surviving field to it. The caller's own loop appended the same fields again, so every model name was doubled: /model gpt-5.6 asked the router for "gpt-5.6 gpt-5.6" and SetActiveModel rejected it as unknown. The index loop becoming a range loop also stopped the space-separated "--provider openai" value being consumed with its flag, so it landed in the name too. Direct model switching over Telegram was broken for everything but --refresh and provider-only switches. splitProviderFlag is now the sole accumulator and returns the surviving fields, so the shared-slice shape that allowed the double append cannot recur (archie-core-0d6). Found while auditing the remaining hunks of6108fc5(archie-core-ifi): the naked return in the same function could not be regression-tested until the function produced correct values. That audit is complete and the other seven hunks are behaviour-neutral. Notably shell.go's errorlint rewrite is not a repeat of the grep failure - it had no companion exit-code condition to drop, and the ctx.Err() timeout check already runs first - and find.go's errors.Is rewrite is safe because errors.Is(err, nil) is false for any non-nil err. Tests cover the return order of parseModelRest (two strings and three bools, so a transposed pair compiles silently), the field count of the model name, and shell's exit-code branch, which had no coverage at all. The find fallback's habit of reporting a cancelled walk as "no matches found" is filed as archie-core-ts9.
34 lines
1.2 KiB
Go
34 lines
1.2 KiB
Go
package builtin
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestShellReportsExitCodeRatherThanAGenericError covers the errorlint autofix
|
|
// in 6d4e0be, which rewrote `err.(*exec.ExitError)` into errors.As here. The
|
|
// same rewrite in grep.go dropped a companion exit-code check and turned failed
|
|
// searches into empty results; this call site had no companion check to lose,
|
|
// but nothing guarded the branch either. If the assertion ever stops matching,
|
|
// a non-zero exit degrades to "error executing command" and the model loses the
|
|
// exit code it uses to tell a failed command from a broken one.
|
|
func TestShellReportsExitCodeRatherThanAGenericError(t *testing.T) {
|
|
tool := NewShellTool(t.TempDir(), nil)
|
|
|
|
result, err := tool.Execute(context.Background(), json.RawMessage(`{"command":"exit 3"}`), nil)
|
|
if err != nil {
|
|
t.Fatalf("execute: %v", err)
|
|
}
|
|
if !result.IsError {
|
|
t.Fatalf("a non-zero exit must be reported as an error, got %#v", result)
|
|
}
|
|
if result.ErrorKind != "command_exit" {
|
|
t.Fatalf("error kind = %q, want command_exit; result: %#v", result.ErrorKind, result)
|
|
}
|
|
if !strings.Contains(result.Content, "[exit code: 3]") {
|
|
t.Fatalf("exit code missing from result: %s", result.Content)
|
|
}
|
|
}
|