Created
August 24, 2017 14:15
-
-
Save marchof/19aebb567ca4598c77b391460da39376 to your computer and use it in GitHub Desktop.
Fixing truncated JaCoCo exec files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jacoco.examples; | |
import java.io.EOFException; | |
import java.io.File; | |
import java.io.IOException; | |
import org.jacoco.core.tools.ExecFileLoader; | |
/** | |
* Loads whatever is available in a truncated JaCoCo exec file and writes it to | |
* a new file. This might be used as a workaround to to get as much information | |
* as possible from broken exec files. Note that your coverage report will be | |
* incomplete in this case. | |
*/ | |
public class ExecFix { | |
public static void main(final String[] args) throws IOException { | |
final ExecFileLoader loader = new ExecFileLoader(); | |
try { | |
loader.load(new File("broken.exec")); | |
} catch (final EOFException e) { | |
// ignore truncated files | |
} | |
loader.save(new File("fixed.exec"), false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment