Skip to content

Commit b09838f

Browse files
committed
Log console contents if AbstractDebugTest.launchAndWait times out
Fixes: #886
1 parent 6da0f46 commit b09838f

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/AbstractDebugTest.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@
154154
import org.eclipse.ui.IWorkbench;
155155
import org.eclipse.ui.IWorkbenchWindow;
156156
import org.eclipse.ui.PlatformUI;
157+
import org.eclipse.ui.console.ConsolePlugin;
157158
import org.eclipse.ui.console.IConsole;
159+
import org.eclipse.ui.console.IConsoleManager;
158160
import org.eclipse.ui.console.IHyperlink;
159161
import org.eclipse.ui.console.TextConsole;
160162
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
@@ -1431,7 +1433,13 @@ protected Object launchAndWait(ILaunchConfiguration configuration, DebugEventWai
14311433
* if the event is never received.
14321434
*/
14331435
protected Object launchAndWait(ILaunchConfiguration configuration, String mode, DebugEventWaiter waiter, boolean register) throws CoreException {
1434-
ILaunch launch = configuration.launch(mode, new TimeoutMonitor(DEFAULT_TIMEOUT), false, register);
1436+
ILaunch launch;
1437+
try {
1438+
launch = configuration.launch(mode, new TimeoutMonitor(DEFAULT_TIMEOUT), false, register);
1439+
} catch (Throwable t) {
1440+
logProcessConsoleContents();
1441+
throw t;
1442+
}
14351443
Object suspendee= waiter.waitForEvent();
14361444
if (suspendee == null) {
14371445
StringBuilder buf = new StringBuilder();
@@ -3144,6 +3152,25 @@ private static void logVMChange(String message, IVMInstall vm) {
31443152
JDIDebugPlugin.log(status);
31453153
}
31463154

3155+
private static void logProcessConsoleContents() {
3156+
try {
3157+
StringBuilder buf = new StringBuilder();
3158+
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
3159+
for (IConsole console : manager.getConsoles()) {
3160+
if (console instanceof ProcessConsole) {
3161+
ProcessConsole processConsole = (ProcessConsole) console;
3162+
String string = processConsole.getDocument().get();
3163+
buf.append("Console output for \"" + processConsole.getName() + "\" follows:\n"); //$NON-NLS-1$
3164+
buf.append(string);
3165+
}
3166+
}
3167+
buf.append("\n"); //$NON-NLS-1$
3168+
DebugPlugin.log(new Status(IStatus.INFO, "org.eclipse.jdt.debug.ui.tests", buf.toString())); //$NON-NLS-1$
3169+
} catch (Throwable t) {
3170+
DebugPlugin.log(t);
3171+
}
3172+
}
3173+
31473174
private static class LogVMInstallChanges implements IVMInstallChangedListener {
31483175

31493176
@Override

0 commit comments

Comments
 (0)