Move native debug accounting into the CLI capture lifecycle

This commit is contained in:
2026-11-23 02:35:19 +00:00
parent 051a91e397
commit 88ebdbd819
5 changed files with 64 additions and 58 deletions

View File

@@ -183,7 +183,7 @@ func TestNativeRunPrimaryFailureSurvivesCaptureAndDiagnosticFailures(t *testing.
app, file, input, _ := runFixture(t, probe)
debug := filepath.Join(filepath.Dir(file), "debug-must-not-exist", "run-1")
probe.onGenerate = func() {
if err := os.Mkdir(filepath.Join(debug, "outcome.json"), 0700); err != nil {
if err := os.Mkdir(filepath.Join(debug, "executions.json"), 0700); err != nil {
t.Error(err)
}
}
@@ -241,31 +241,35 @@ func TestNativeRunDiagnosticDeliveryFailureIsNotAnOperationFailure(t *testing.T)
}
func TestNativeRunCaptureFailureAfterPublicationDoesNotReportSuccess(t *testing.T) {
probe := &runProbe{}
app, file, input, _ := runFixture(t, probe)
var once sync.Once
debug := filepath.Join(filepath.Dir(file), "debug-must-not-exist", "run-1")
probe.onGenerate = func() {
once.Do(func() {
// The external provider boundary runs after capture allocation but
// before terminalization. Make only the terminal file unusable.
if err := os.Mkdir(filepath.Join(debug, "outcome.json"), 0700); err != nil {
t.Fatal(err)
for _, blocked := range []string{"outcome.json", "executions.json"} {
t.Run(blocked, func(t *testing.T) {
probe := &runProbe{}
app, file, input, _ := runFixture(t, probe)
var once sync.Once
debug := filepath.Join(filepath.Dir(file), "debug-must-not-exist", "run-1")
probe.onGenerate = func() {
once.Do(func() {
// The external provider boundary runs after capture allocation but
// before terminalization. Make only this final capture file unusable.
if err := os.Mkdir(filepath.Join(debug, blocked), 0700); err != nil {
t.Fatal(err)
}
})
}
var output, diagnostics bytes.Buffer
outcome := app.Execute(context.Background(), []string{"run", "demo", "--config", file, "--input-file", input, "--cache", "bypass", "--debug", "--format", "json"}, commandkit.Streams{Out: &output, Err: &diagnostics})
if outcome.Status != 1 || outcome.Cause == nil || output.Len() != 0 || probe.produced != 1 {
t.Fatalf("post-publication capture failure: %#v stdout=%s stderr=%s", outcome, output.String(), diagnostics.String())
}
assertCompletedRunFiles(t, file, false)
if !strings.Contains(diagnostics.String(), debug) || !strings.Contains(diagnostics.String(), filepath.Join(filepath.Dir(file), "output-must-not-exist", "run-1")) {
t.Fatalf("post-publication locations: %s", diagnostics.String())
}
if _, err := os.Stat(filepath.Join(debug, "context.json")); err != nil {
t.Fatalf("existing capture was removed: %v", err)
}
})
}
var output, diagnostics bytes.Buffer
outcome := app.Execute(context.Background(), []string{"run", "demo", "--config", file, "--input-file", input, "--cache", "bypass", "--debug", "--format", "json"}, commandkit.Streams{Out: &output, Err: &diagnostics})
if outcome.Status != 1 || outcome.Cause == nil || output.Len() != 0 || probe.produced != 1 {
t.Fatalf("post-publication capture failure: %#v stdout=%s stderr=%s", outcome, output.String(), diagnostics.String())
}
assertCompletedRunFiles(t, file, false)
if !strings.Contains(diagnostics.String(), debug) || !strings.Contains(diagnostics.String(), filepath.Join(filepath.Dir(file), "output-must-not-exist", "run-1")) {
t.Fatalf("post-publication locations: %s", diagnostics.String())
}
if _, err := os.Stat(filepath.Join(debug, "executions.json")); err != nil {
t.Fatalf("existing capture was removed: %v", err)
}
}
func TestNativeRunFailureCategoriesPreserveCausesWithoutSuccessReports(t *testing.T) {