Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug launch thread hang using modified denyska patch. #148

Merged
merged 1 commit into from May 22, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -338,10 +338,10 @@ private void stopUpdateJobs() {
}
}

public void startTestRunListening(IJavaProject project,
public void startTestRunListening(final IJavaProject project,
String subName,
int port,
ILaunch launch) {
final ILaunch launch) {
m_workingProject = project;

aboutToLaunch(subName);
Expand All @@ -350,39 +350,46 @@ public void startTestRunListening(IJavaProject project,
// stopTest();
// }
fTestRunnerClient = new EclipseTestRunnerClient();
IMessageSender messageMarshaller = LaunchUtil.useStringProtocol(launch.getLaunchConfiguration())
final IMessageSender messageMarshaller = LaunchUtil.useStringProtocol(launch.getLaunchConfiguration())
? new StringMessageSender("localhost", port)
: new SerializedMessageSender("localhost", port);

boolean isInitSuccess = false;
do {
try {
messageMarshaller.initReceiver();
isInitSuccess = true;
} catch (SocketTimeoutException e) {
TestNGPlugin.log(e);
}
} while (isInitSuccess == false && launch.isTerminated() == false);

if (isInitSuccess == true) {
newSuiteRunInfo(launch);

fTestRunnerClient.startListening(currentSuiteRunInfo, currentSuiteRunInfo, messageMarshaller);
m_rerunAction.setEnabled(true);
m_rerunFailedAction.setEnabled(false);
m_openReportAction.setEnabled(true);
} else {
boolean useProjectJar =
TestNGPlugin.getPluginPreferenceStore().getUseProjectJar(project.getProject().getName());
String suggestion = useProjectJar
? "Uncheck the 'Use Project testng.jar' option from your Project properties and try again."
: "Make sure you don't have an older version of testng.jar on your class path.";
new ErrorDialog(m_counterComposite.getShell(), "Couldn't launch TestNG",
"Couldn't contact the RemoteTestNG client. " + suggestion,
new StatusInfo(IStatus.ERROR, "Timeout while trying to contact RemoteTestNG."),
IStatus.ERROR).open();
}
// getViewSite().getActionBars().updateActionBars();
String jobName = ResourceUtil.getString("TestRunnerViewPart.message.startTestRunListening");
Job testRunListeningJob = new Job(jobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
messageMarshaller.initReceiver();
newSuiteRunInfo(launch);
fTestRunnerClient.startListening(currentSuiteRunInfo, currentSuiteRunInfo, messageMarshaller);

postSyncRunnable(new Runnable() {
public void run() {
m_rerunAction.setEnabled(true);
m_rerunFailedAction.setEnabled(false);
m_openReportAction.setEnabled(true);
}
});
}
catch(SocketTimeoutException ex) {
postSyncRunnable(new Runnable() {
public void run() {
boolean useProjectJar =
TestNGPlugin.getPluginPreferenceStore().getUseProjectJar(project.getProject().getName());
String suggestion = useProjectJar
? "Uncheck the 'Use Project testng.jar' option from your Project properties and try again."
: "Make sure you don't have an older version of testng.jar on your class path.";
new ErrorDialog(m_counterComposite.getShell(), "Couldn't launch TestNG",
"Couldn't contact the RemoteTestNG client. " + suggestion,
new StatusInfo(IStatus.ERROR, "Timeout while trying to contact RemoteTestNG."),
IStatus.ERROR).open();
}
});
}
return Status.OK_STATUS;
}
};
testRunListeningJob.schedule();
}

/**
Expand Down