Complete diagnostics retention semantics
This commit is contained in:
@@ -478,6 +478,98 @@ func TestRunProcessFailedRunRetainedWithNeverRetention(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunProcessSuccessfulRunAutoRetentionRemovesRunDir(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
workDir := t.TempDir()
|
||||
reportPath := filepath.Join(t.TempDir(), "report.json")
|
||||
|
||||
exitCode := Run([]string{
|
||||
"process",
|
||||
fixturePath("tiny_transcript.json"),
|
||||
"--glossary",
|
||||
fixturePath("tiny_glossary.yaml"),
|
||||
"--work-dir",
|
||||
workDir,
|
||||
"--work-dir-retention",
|
||||
"auto",
|
||||
"--report-json",
|
||||
reportPath,
|
||||
}, &stdout, &stderr)
|
||||
if exitCode != 0 {
|
||||
t.Fatalf("expected exit code 0, got %d with stderr %q", exitCode, stderr.String())
|
||||
}
|
||||
|
||||
entries, err := os.ReadDir(workDir)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read work dir: %v", err)
|
||||
}
|
||||
if len(entries) != 0 {
|
||||
t.Fatalf("expected auto retention to remove successful clean run dir, found %d entries", len(entries))
|
||||
}
|
||||
|
||||
// Explicit report path must still exist even if run dir is removed.
|
||||
if _, err := os.Stat(reportPath); err != nil {
|
||||
t.Fatalf("expected --report-json output to survive run-dir removal: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunProcessSuccessfulRunAlwaysRetentionKeepsRunDir(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
workDir := t.TempDir()
|
||||
|
||||
exitCode := Run([]string{
|
||||
"process",
|
||||
fixturePath("tiny_transcript.json"),
|
||||
"--glossary",
|
||||
fixturePath("tiny_glossary.yaml"),
|
||||
"--work-dir",
|
||||
workDir,
|
||||
"--work-dir-retention",
|
||||
"always",
|
||||
}, &stdout, &stderr)
|
||||
if exitCode != 0 {
|
||||
t.Fatalf("expected exit code 0, got %d with stderr %q", exitCode, stderr.String())
|
||||
}
|
||||
|
||||
runPath := onlyRunDir(t, workDir)
|
||||
if _, err := os.Stat(runPath); err != nil {
|
||||
t.Fatalf("expected run dir retained under always: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunProcessFailedRunRetainedWithAutoRetention(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
workDir := t.TempDir()
|
||||
|
||||
exitCode := Run([]string{
|
||||
"process",
|
||||
schemaFixturePath("transcript_empty_speaker.json"),
|
||||
"--glossary",
|
||||
fixturePath("tiny_glossary.yaml"),
|
||||
"--work-dir",
|
||||
workDir,
|
||||
"--work-dir-retention",
|
||||
"auto",
|
||||
}, &stdout, &stderr)
|
||||
if exitCode == 0 {
|
||||
t.Fatalf("expected nonzero exit code")
|
||||
}
|
||||
if stdout.Len() != 0 {
|
||||
t.Fatalf("expected empty stdout on failure, got %q", stdout.String())
|
||||
}
|
||||
|
||||
runPath := onlyRunDir(t, workDir)
|
||||
if _, err := os.Stat(filepath.Join(runPath, "error.log")); err != nil {
|
||||
t.Fatalf("expected error.log in retained failed run under auto: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunProcessReportJSONIncludesChunkingSummary(t *testing.T) {
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user