def testNineToTenLogs(self): """Test handling *.log.9 to *.log.10 (correct sorting).""" self._generateLogs(9) cbuildbot._BackupPreviousLog(os.path.join(self.tempdir, 'cbuildbot.log'), backup_limit=25) with open(os.path.join(self.tempdir, 'cbuildbot.log.10')) as f: self.assertEquals(f.readline(), '10')
def testZeroToOneLogs(self): """Test beginning corner case.""" self._generateLogs(0) cbuildbot._BackupPreviousLog(os.path.join(self.tempdir, 'cbuildbot.log'), backup_limit=25) with open(os.path.join(self.tempdir, 'cbuildbot.log.1')) as f: self.assertEquals(f.readline(), '1')
def testOverLimit(self): """Test going over the limit and having to purge old logs.""" self._generateLogs(25) cbuildbot._BackupPreviousLog(os.path.join(self.tempdir, "cbuildbot.log"), backup_limit=25) with open(os.path.join(self.tempdir, "cbuildbot.log.26")) as f: self.assertEquals(f.readline(), "26") self.assertEquals(len(glob.glob(os.path.join(self.tempdir, "cbuildbot*"))), 25)
def testOverLimit(self): """Test going over the limit and having to purge old logs.""" self._generateLogs(25) cbuildbot._BackupPreviousLog(os.path.join(self.tempdir, 'cbuildbot.log'), backup_limit=25) with open(os.path.join(self.tempdir, 'cbuildbot.log.26')) as f: self.assertEquals(f.readline(), '26') self.assertEquals(len(glob.glob(os.path.join(self.tempdir, 'cbuildbot*'))), 25)