Show progress for each preflight profile

This commit is contained in:
2026-11-27 04:04:30 +00:00
parent 2eae2a4af2
commit 7ba1846e63
5 changed files with 35 additions and 6 deletions

View File

@@ -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})

View File

@@ -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)
}
}