Skip to content

Commit

Permalink
Merge pull request #1261 from hcoles/bug/error_reading_old_history_files
Browse files Browse the repository at this point in the history
do not error when given old history file
  • Loading branch information
hcoles authored Oct 10, 2023
2 parents 5de5b7e + 99a37be commit fe80e4d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void restoreResults() {
this.previousResults.put(result.id, result.status);
line = this.input.readLine();
}
} catch (final IOException e) {
} catch (final Exception e) {
LOG.warning("Could not read previous results");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,37 @@ public void shouldReadCorruptFiles() throws IOException {
assertFalse(this.testee.getHistoricResults().isEmpty());
}

@Test
public void doesNotErrorOnOldHistoryFile() throws IOException {
final HierarchicalClassId foo = new HierarchicalClassId(
new ClassIdentifier(0, ClassName.fromString("foo")), "");
recordClassPathWithTestee(foo);

final MutationResult mr = new MutationResult(
MutationTestResultMother.createDetails("foo"),
new MutationStatusTestPair(1, DetectionStatus.KILLED, "testName"));

this.testee.recordResult(mr);
this.output.append(pitest14HistoryFile());

final Reader reader = new StringReader(this.output.toString());
this.testee = new ObjectOutputStreamHistory(this.code, this.writerFactory,
Optional.ofNullable(reader));
this.testee.initialize();

assertFalse(this.testee.getHistoricResults().isEmpty());
}

private String pitest14HistoryFile() {
return "rO0ABXNyACRvcmcucGl0ZXN0Lm11dGF0aW9udGVzdC5DbGFzc0hpc3RvcnkAAAAAAAAAAQIAAkwACmNvdmVyYWdlSWR0ABJMamF2YS9sYW5nL1N0cmluZztM" +
"AAJpZHQAKkxvcmcvcGl0ZXN0L2NsYXNzaW5mby9IaWVyYXJjaGljYWxDbGFzc0lkO3hwdAAIMTY1MmVhMDRzcgAob3JnLnBpdGVzdC5jbGFzc2luZm8uSGllc" +
"mFyY2hpY2FsQ2xhc3NJZAAAAAAAAAABAgACTAAHY2xhc3NJZHQAJkxvcmcvcGl0ZXN0L2NsYXNzaW5mby9DbGFz" +
"c0lkZW50aWZpZXI7TAAQaGllcmFyY2hpY2FsSGFzaHEAfgABeHBzcgAkb3JnLnBpdGVzdC5jbGFzc2luZm8uQ2xhc3NJZGVudGl" +
"maWVyAAAAAAAAAAECAAJKAARoYXNoTAAEbmFtZXQAIExvcmcvcGl0ZXN0L2NsYXNzaW5mby9DbGFzc05hbWU7eHAAAAAAFlLqBHNyAB5" +
"vcmcucGl0ZXN0LmNsYXNzaW5mby5DbGFzc05hbWUAAAAAAAAAAQIAAUwABG5hbWVxAH4AAXhwdAAkY29tL2V4YW1wbGUvbW9kdWxlYi9DYX" +
"RDb252ZXJ0ZXJUZXN0dAAIMTY1MmVhMDQ=";
}

private void recordClassPathWithTestee(
final HierarchicalClassId... classIdentifiers) {
this.testee = new ObjectOutputStreamHistory(this.code, this.writerFactory,
Expand Down

0 comments on commit fe80e4d

Please sign in to comment.