Limit cleanup checks to owned diagnostic views
This commit is contained in:
@@ -34,7 +34,11 @@ func cleanRunWithRetainedBundle(workspaceRoot, runRoot string, remove bool) (boo
|
||||
return false, fmt.Errorf("invalid run cleanup directory %q", runRoot)
|
||||
}
|
||||
sessionRoot := filepath.Dir(runsDir)
|
||||
targets, err := fileops.ManagedAttemptTargets(sessionRoot, filepath.Base(runRoot))
|
||||
names := []string{"restore"}
|
||||
for _, stage := range All() {
|
||||
names = append(names, stage.Name())
|
||||
}
|
||||
targets, err := fileops.ManagedAttemptTargets(sessionRoot, filepath.Base(runRoot), names)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("resolve managed diagnostic targets: %w", err)
|
||||
}
|
||||
|
||||
@@ -49,6 +49,13 @@ func TestCleanupPreservesLatestViewsAcrossRunsAndRemovesOldDiagnostics(t *testin
|
||||
writeStageTestFile(t, kept, "current")
|
||||
writeStageTestFile(t, old, "old")
|
||||
writeStageTestFile(t, filepath.Join(root, "polish", "outputs", "work.json"), "work")
|
||||
for _, category := range []string{"logs", "debug"} {
|
||||
writeStageTestFile(t, filepath.Join(session.Root, category, "README.txt"), "operator notes")
|
||||
writeStageTestFile(t, filepath.Join(session.Root, category, "notes", "keep.txt"), "keep")
|
||||
if err := os.Symlink("../../outside", filepath.Join(session.Root, category, "operator-link")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if _, err := (cleanupStage{}).Run(context.Background(), env, m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -78,6 +85,13 @@ func TestCleanupPreservesLatestViewsAcrossRunsAndRemovesOldDiagnostics(t *testin
|
||||
if _, err := os.Stat(filepath.Join(session.Root, "logs", "merge")); err != nil {
|
||||
t.Fatalf("newer merge view: %v", err)
|
||||
}
|
||||
for _, category := range []string{"logs", "debug"} {
|
||||
for _, name := range []string{"README.txt", "notes/keep.txt", "operator-link"} {
|
||||
if _, err := os.Lstat(filepath.Join(session.Root, category, name)); err != nil {
|
||||
t.Fatalf("unrelated content removed: %s/%s: %v", category, name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupStageRemovesOnlySelectedPublishedRunTarget(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user