Show progress for each preflight profile
This commit is contained in:
@@ -34,7 +34,9 @@ func runPreflight(inv commandkit.Invocation, input processInput) commandkit.Outc
|
||||
return commandkit.Success()
|
||||
}
|
||||
_ = reporter.Progress("Checking structured output for selected profiles.")
|
||||
results, err := llm.VerifyStructuredOutput(inv.Context, loaded.Runtime.Engine, prepared.Plan.Profiles)
|
||||
results, err := llm.VerifyStructuredOutput(inv.Context, loaded.Runtime.Engine, prepared.Plan.Profiles, func(id string) {
|
||||
_ = reporter.Progress(fmt.Sprintf("Checking structured output for profile %q.", id))
|
||||
})
|
||||
if err != nil {
|
||||
details := make([]commandkit.Detail, 0, len(results))
|
||||
for _, result := range results {
|
||||
|
||||
@@ -213,11 +213,16 @@ func TestPreflightExplainsNativePreparationError(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, flags := range [][]string{nil, {"--quiet"}, {"--debug"}} {
|
||||
for _, flags := range [][]string{nil, {"--quiet"}, {"--debug"}, {"--progress"}, {"--progress=false"}, {"--quiet", "--progress"}} {
|
||||
var out, diagnostic bytes.Buffer
|
||||
args := append([]string{"preflight"}, flags...)
|
||||
args = append(args, "--config", filepath.Join(dir, "config.yml"), "--output", filepath.Join(dir, "out.json"), filepath.Join(dir, "transcript.json"))
|
||||
result := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostic})
|
||||
wantProgress := slices.Contains(flags, "--debug") || (slices.Contains(flags, "--progress") && !slices.Contains(flags, "--quiet"))
|
||||
if strings.Contains(diagnostic.String(), `Checking structured output for profile "selected"`) != wantProgress {
|
||||
t.Fatalf("flags=%v diagnostic=%s", flags, diagnostic.String())
|
||||
}
|
||||
|
||||
if result.Status != 1 || result.Cause == nil || !strings.Contains(diagnostic.String(), `Profile "selected"`) || !strings.Contains(diagnostic.String(), "model is required") {
|
||||
t.Fatalf("status=%d cause=%v diagnostic=%s", result.Status, result.Cause, diagnostic.String())
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func classifyStructuredOutput(report *pk.SmokeTestReport, err error) Verificatio
|
||||
}
|
||||
|
||||
// VerifyStructuredOutput checks selected profiles sequentially and retains native evidence.
|
||||
func VerifyStructuredOutput(ctx context.Context, engine smokeTester, profiles []string) ([]ProfileVerification, error) {
|
||||
func VerifyStructuredOutput(ctx context.Context, engine smokeTester, profiles []string, progress func(string)) ([]ProfileVerification, error) {
|
||||
var results []ProfileVerification
|
||||
var failures []error
|
||||
for _, id := range profiles {
|
||||
@@ -69,6 +69,9 @@ func VerifyStructuredOutput(ctx context.Context, engine smokeTester, profiles []
|
||||
failures = append(failures, err)
|
||||
break
|
||||
}
|
||||
if progress != nil {
|
||||
progress(id)
|
||||
}
|
||||
report, err := engine.SmokeTest(ctx, pk.SmokeTestRequest{Kind: pk.SmokeTestStructuredOutput, ProfileID: id})
|
||||
status := classifyStructuredOutput(report, err)
|
||||
results = append(results, ProfileVerification{ProfileID: id, Status: status, Report: report, Err: err})
|
||||
|
||||
@@ -79,7 +79,7 @@ func TestVerifyStructuredOutputContinuesAndStopsOnCancellation(t *testing.T) {
|
||||
return positiveSmokeReport(), nil
|
||||
}
|
||||
})
|
||||
results, err := VerifyStructuredOutput(ctx, engine, []string{"first", "second", "third"})
|
||||
results, err := VerifyStructuredOutput(ctx, engine, []string{"first", "second", "third"}, nil)
|
||||
if !slices.Equal(calls, []string{"first", "second"}) || len(results) != 2 || results[1].Report == nil || !errors.Is(err, failure) || !errors.Is(err, context.Canceled) {
|
||||
t.Fatalf("calls=%v results=%+v error=%v", calls, results, err)
|
||||
}
|
||||
@@ -111,8 +111,22 @@ func TestVerifyStructuredOutputUsesNativeEngine(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
results, err := VerifyStructuredOutput(context.Background(), runtime.Engine, []string{"fixture"})
|
||||
results, err := VerifyStructuredOutput(context.Background(), runtime.Engine, []string{"fixture"}, nil)
|
||||
if err != nil || calls != 1 || len(results) != 1 || results[0].Status != VerificationSuccess {
|
||||
t.Fatalf("calls=%d results=%+v err=%v", calls, results, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVerificationIdentifiesProfileBeforeDispatch(t *testing.T) {
|
||||
var current string
|
||||
engine := smokeFunc(func(_ context.Context, req pk.SmokeTestRequest) (*pk.SmokeTestReport, error) {
|
||||
if current != req.ProfileID {
|
||||
t.Fatalf("progress %q before dispatch %q", current, req.ProfileID)
|
||||
}
|
||||
return positiveSmokeReport(), nil
|
||||
})
|
||||
_, err := VerifyStructuredOutput(context.Background(), engine, []string{"one", "two"}, func(id string) { current = id })
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user