[Fix] TexHelperTest detects if pdflatex is installed before trying to run
This commit is contained in:
parent
0a227cd2e3
commit
48b0639b16
|
@ -7,12 +7,16 @@ import java.io.File;
|
|||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TexHelperTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Assume.assumeThat(true, new PdfLatexChecker());
|
||||
|
||||
File texDir = new File("src/test/resources");
|
||||
String templateName = "tex.tpl";
|
||||
|
@ -40,4 +44,25 @@ public class TexHelperTest {
|
|||
assertNotNull(renderFile);
|
||||
assertTrue(renderFile.exists());
|
||||
}
|
||||
|
||||
private static class PdfLatexChecker extends TypeSafeMatcher<Boolean> {
|
||||
@Override
|
||||
protected boolean matchesSafely(Boolean b) {
|
||||
|
||||
int result;
|
||||
try {
|
||||
Process exec = Runtime.getRuntime().exec("pdflatex --version");
|
||||
result = exec.waitFor();
|
||||
} catch (Exception e) {
|
||||
result = 99;
|
||||
}
|
||||
|
||||
return b ? result == 0 : result > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("validate PDF Latex is installed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue