Skip to content

Commit 7a450bf

Browse files
trancexpressiloveeclipse
authored andcommitted
Log console contents if AbstractDebugTest.launchAndWait times out
Fixes: #886
1 parent 96978df commit 7a450bf

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

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
@@ -155,7 +155,9 @@
155155
import org.eclipse.ui.IWorkbench;
156156
import org.eclipse.ui.IWorkbenchWindow;
157157
import org.eclipse.ui.PlatformUI;
158+
import org.eclipse.ui.console.ConsolePlugin;
158159
import org.eclipse.ui.console.IConsole;
160+
import org.eclipse.ui.console.IConsoleManager;
159161
import org.eclipse.ui.console.IHyperlink;
160162
import org.eclipse.ui.console.TextConsole;
161163
import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition;
@@ -1432,7 +1434,13 @@ protected Object launchAndWait(ILaunchConfiguration configuration, DebugEventWai
14321434
* if the event is never received.
14331435
*/
14341436
protected Object launchAndWait(ILaunchConfiguration configuration, String mode, DebugEventWaiter waiter, boolean register) throws CoreException {
1435-
ILaunch launch = configuration.launch(mode, new TimeoutMonitor(DEFAULT_TIMEOUT), false, register);
1437+
ILaunch launch;
1438+
try {
1439+
launch = configuration.launch(mode, new TimeoutMonitor(DEFAULT_TIMEOUT), false, register);
1440+
} catch (Throwable t) {
1441+
logProcessConsoleContents();
1442+
throw t;
1443+
}
14361444
Object suspendee= waiter.waitForEvent();
14371445
if (suspendee == null) {
14381446
StringBuilder buf = new StringBuilder();
@@ -3146,6 +3154,25 @@ private static void logVMChange(String message, IVMInstall vm) {
31463154
JDIDebugPlugin.log(status);
31473155
}
31483156

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

31513178
@Override

0 commit comments

Comments
 (0)