diff --git a/pkg/status_file/bin/remove_non_essential_entries.dart b/pkg/status_file/bin/remove_non_essential_entries.dart index 4b1c6c584f1..80cd9300985 100644 --- a/pkg/status_file/bin/remove_non_essential_entries.dart +++ b/pkg/status_file/bin/remove_non_essential_entries.dart @@ -41,7 +41,7 @@ StatusFile removeNonEssentialEntries( StatusFile statusFile, List expectationsToKeep) { List sections = []; for (StatusSection section in statusFile.sections) { - bool hasOnlyEmptyEntries = section.sectionHeaderComments.isEmpty; + bool hasStatusEntries = false; List entries = []; for (Entry entry in section.entries) { if (entry is EmptyEntry) { @@ -49,18 +49,20 @@ StatusFile removeNonEssentialEntries( } else if (entry is StatusEntry && entry.comment != null || entry is CommentEntry) { entries.add(entry); - hasOnlyEmptyEntries = false; + hasStatusEntries = true; } else if (entry is StatusEntry) { StatusEntry newEntry = filterExpectations(entry, expectationsToKeep); if (newEntry != null) { entries.add(newEntry); - hasOnlyEmptyEntries = false; + hasStatusEntries = true; } } else { throw "Unknown entry type ${entry.runtimeType}"; } } - if (!hasOnlyEmptyEntries || section.sectionHeaderComments.isNotEmpty) { + bool isDefaultSection = section.condition == null; + if (hasStatusEntries || + (isDefaultSection && section.sectionHeaderComments.isNotEmpty)) { StatusSection newSection = StatusSection(section.condition, -1, section.sectionHeaderComments); newSection.entries.addAll(entries);