Skip to content

Commit fe80e4d

Browse files
authored
Merge pull request #1261 from hcoles/bug/error_reading_old_history_files
do not error when given old history file
2 parents 5de5b7e + 99a37be commit fe80e4d

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

pitest-entry/src/main/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private void restoreResults() {
127127
this.previousResults.put(result.id, result.status);
128128
line = this.input.readLine();
129129
}
130-
} catch (final IOException e) {
130+
} catch (final Exception e) {
131131
LOG.warning("Could not read previous results");
132132
}
133133
}

pitest-entry/src/test/java/org/pitest/mutationtest/incremental/ObjectOutputStreamHistoryTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,37 @@ public void shouldReadCorruptFiles() throws IOException {
147147
assertFalse(this.testee.getHistoricResults().isEmpty());
148148
}
149149

150+
@Test
151+
public void doesNotErrorOnOldHistoryFile() throws IOException {
152+
final HierarchicalClassId foo = new HierarchicalClassId(
153+
new ClassIdentifier(0, ClassName.fromString("foo")), "");
154+
recordClassPathWithTestee(foo);
155+
156+
final MutationResult mr = new MutationResult(
157+
MutationTestResultMother.createDetails("foo"),
158+
new MutationStatusTestPair(1, DetectionStatus.KILLED, "testName"));
159+
160+
this.testee.recordResult(mr);
161+
this.output.append(pitest14HistoryFile());
162+
163+
final Reader reader = new StringReader(this.output.toString());
164+
this.testee = new ObjectOutputStreamHistory(this.code, this.writerFactory,
165+
Optional.ofNullable(reader));
166+
this.testee.initialize();
167+
168+
assertFalse(this.testee.getHistoricResults().isEmpty());
169+
}
170+
171+
private String pitest14HistoryFile() {
172+
return "rO0ABXNyACRvcmcucGl0ZXN0Lm11dGF0aW9udGVzdC5DbGFzc0hpc3RvcnkAAAAAAAAAAQIAAkwACmNvdmVyYWdlSWR0ABJMamF2YS9sYW5nL1N0cmluZztM" +
173+
"AAJpZHQAKkxvcmcvcGl0ZXN0L2NsYXNzaW5mby9IaWVyYXJjaGljYWxDbGFzc0lkO3hwdAAIMTY1MmVhMDRzcgAob3JnLnBpdGVzdC5jbGFzc2luZm8uSGllc" +
174+
"mFyY2hpY2FsQ2xhc3NJZAAAAAAAAAABAgACTAAHY2xhc3NJZHQAJkxvcmcvcGl0ZXN0L2NsYXNzaW5mby9DbGFz" +
175+
"c0lkZW50aWZpZXI7TAAQaGllcmFyY2hpY2FsSGFzaHEAfgABeHBzcgAkb3JnLnBpdGVzdC5jbGFzc2luZm8uQ2xhc3NJZGVudGl" +
176+
"maWVyAAAAAAAAAAECAAJKAARoYXNoTAAEbmFtZXQAIExvcmcvcGl0ZXN0L2NsYXNzaW5mby9DbGFzc05hbWU7eHAAAAAAFlLqBHNyAB5" +
177+
"vcmcucGl0ZXN0LmNsYXNzaW5mby5DbGFzc05hbWUAAAAAAAAAAQIAAUwABG5hbWVxAH4AAXhwdAAkY29tL2V4YW1wbGUvbW9kdWxlYi9DYX" +
178+
"RDb252ZXJ0ZXJUZXN0dAAIMTY1MmVhMDQ=";
179+
}
180+
150181
private void recordClassPathWithTestee(
151182
final HierarchicalClassId... classIdentifiers) {
152183
this.testee = new ObjectOutputStreamHistory(this.code, this.writerFactory,

0 commit comments

Comments
 (0)