summaryrefslogtreecommitdiff
path: root/unotest
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-04-03 10:55:00 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-04-03 10:55:00 +0200
commitb8c87dee815d9d20b65fe97e6f838c6937cdf6ab (patch)
tree41fa4ebeb67da8103f5cc930c511eaad2755ea33 /unotest
parentb524fb866e905c44f309c222ba1f44dad6375611 (diff)
Show backtraces for core files from CppunitTests, too
Change-Id: Idff2831913b6fb6e5b522ae36fffeb345e3a1140
Diffstat (limited to 'unotest')
-rw-r--r--unotest/source/java/org/openoffice/test/OfficeConnection.java73
1 files changed, 44 insertions, 29 deletions
diff --git a/unotest/source/java/org/openoffice/test/OfficeConnection.java b/unotest/source/java/org/openoffice/test/OfficeConnection.java
index d8774a1958c7..de6e7054ff4b 100644
--- a/unotest/source/java/org/openoffice/test/OfficeConnection.java
+++ b/unotest/source/java/org/openoffice/test/OfficeConnection.java
@@ -43,11 +43,6 @@ import static org.junit.Assert.*;
public final class OfficeConnection {
- private final class PostprocessFailedException extends java.lang.RuntimeException {
- PostprocessFailedException() {
- super("This likely means that soffice crashed during the test.");
- }
- };
/** Start up an OOo instance.
*/
public void setUp() throws Exception {
@@ -108,6 +103,7 @@ public final class OfficeConnection {
public void tearDown()
throws InterruptedException, com.sun.star.uno.Exception
{
+ boolean cleanTermination = false;
try {
boolean desktopTerminated = true;
if (process != null) {
@@ -148,38 +144,45 @@ public final class OfficeConnection {
if (process != null) {
code = process.waitFor();
}
- boolean outTerminated = outForward == null || outForward.terminated();
- boolean errTerminated = errForward == null || errForward.terminated();
+ boolean outTerminated = outForward == null
+ || outForward.terminated();
+ boolean errTerminated = errForward == null
+ || errForward.terminated();
assertEquals(0, code);
+ cleanTermination = true;
assertTrue(outTerminated);
assertTrue(errTerminated);
} finally {
- try {
- String sofficeArg = Argument.get("soffice");
- String workdir = Argument.get("workdir");
- String postprocesscommand = Argument.get("postprocesscommand");
- if(sofficeArg.startsWith("path:") && workdir != null && postprocesscommand != null) {
- ProcessBuilder pb = new ProcessBuilder(
- postprocesscommand,
- sofficeArg.substring("path:".length()),
- workdir);
- Process postprocess = pb.start();
- Forward ppoutForward = new Forward(postprocess.getInputStream(), System.out);
- ppoutForward.start();
- Forward pperrForward = new Forward(postprocess.getErrorStream(), System.err);
- pperrForward.start();
- postprocess.waitFor();
- if(postprocess.exitValue() != 0)
+ if (!cleanTermination) {
+ try {
+ String sofficeArg = Argument.get("soffice");
+ String workdir = Argument.get("workdir");
+ String postprocesscommand = Argument.get(
+ "postprocesscommand");
+ if (sofficeArg.startsWith("path:") && workdir != null
+ && postprocesscommand != null)
{
- // no ugly long java stacktrace needed here
- PostprocessFailedException e = new PostprocessFailedException();
- StackTraceElement[] newStackTrace = new StackTraceElement[0];
- e.setStackTrace(newStackTrace);
- throw e;
+ ProcessBuilder pb = new ProcessBuilder(
+ postprocesscommand,
+ sofficeArg.substring("path:".length()) + ".bin",
+ workdir);
+ Process postprocess = pb.start();
+ Forward ppoutForward = new Forward(
+ postprocess.getInputStream(), System.out);
+ ppoutForward.start();
+ Forward pperrForward = new Forward(
+ postprocess.getErrorStream(), System.err);
+ pperrForward.start();
+ int code = postprocess.waitFor();
+ if (code != 0) {
+ throw new PostprocessFailedException(code);
+ }
}
}
+ catch (IOException e) {
+ throw new PostprocessFailedException(e);
+ }
}
- catch(IOException e) {}
}
}
@@ -262,6 +265,18 @@ public final class OfficeConnection {
private boolean done = false;
}
+ private static final class PostprocessFailedException
+ extends RuntimeException
+ {
+ PostprocessFailedException(int exitCode) {
+ super("postprocessing failed with exit code " + exitCode);
+ }
+
+ PostprocessFailedException(IOException cause) {
+ super("postprocessing failed with IOException " + cause, cause);
+ }
+ };
+
private String description;
private Process process = null;
private Forward outForward = null;