This commit is contained in:
LZX committed 2026-09-16 21:52:25 +08:00
1 parent 59125d185c
commit 5ac164b407
18 files changed
+2249 -43

No files matched your search

+52 -2
View File
@@ -347,9 +347,59 @@ gcc main.c -o app
);
session.write('Some previous output');
session.clear();
// clear emits VT100 ANSI sequences
expect(session.bufferText.trim(), isEmpty);
session.dispose();
});
});
group('PackageManager Lock Cleanup & Self Healing Tests', () {
test('cleanStaleLocks removes APT/dpkg, APK, RPM, and /etc lock files', () {
final tempDir = Directory.systemTemp.createTempSync('lock_cleanup_test_');
try {
// Create dummy lock files
final filesToCreate = [
'etc/group.lock',
'etc/passwd.lock',
'var/lib/dpkg/lock',
'var/lib/dpkg/lock-frontend',
'var/lib/apt/lists/lock',
'var/cache/apt/archives/lock',
'lib/apk/db/lock',
'var/lib/rpm/.rpm.lock',
];
for (final rel in filesToCreate) {
final file = File(p.join(tempDir.path, rel));
file.createSync(recursive: true);
expect(file.existsSync(), isTrue);
}
// Non-lock files should not be deleted
final normalFile = File(p.join(tempDir.path, 'var/lib/dpkg/status'));
normalFile.createSync(recursive: true);
DistroManager().cleanStaleLocks(tempDir);
for (final rel in filesToCreate) {
final file = File(p.join(tempDir.path, rel));
expect(file.existsSync(), isFalse, reason: '$rel should have been deleted');
}
expect(normalFile.existsSync(), isTrue, reason: 'Normal status file should remain');
} finally {
if (tempDir.existsSync()) {
tempDir.deleteSync(recursive: true);
}
}
});
test('ToolchainRequirement getInstallCommand automatically adds dpkg self-healing for Ubuntu and Debian', () {
final makeReq = ToolchainService.supportedTools['make']!;
final ubuntuCmd = makeReq.getInstallCommand(DistroFamily.ubuntu);
final debianCmd = makeReq.getInstallCommand(DistroFamily.debian);
final alpineCmd = makeReq.getInstallCommand(DistroFamily.alpine);
expect(ubuntuCmd, contains('dpkg --configure -a'));
expect(debianCmd, contains('dpkg --configure -a'));
expect(alpineCmd, isNot(contains('dpkg --configure -a')));
});
});
}