Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.ProcessBuilder.Redirect;
import java.nio.file.Files;
import java.nio.file.Path;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.List;
Expand Down Expand Up @@ -51,6 +53,7 @@
*/
public class Test_org_eclipse_swt_dnd_Clipboard {

private static final int DEFAULT_TIMEOUT_MS = 10000;
@TempDir
static Path tempFolder;
static int uniqueId = 1;
Expand Down Expand Up @@ -168,16 +171,40 @@ private void startRemoteClipboardCommands() throws Exception {
throw new RuntimeException("Failed to get port");
});
assertNotEquals(0, port);
Registry reg = LocateRegistry.getRegistry("127.0.0.1", port);
long stopTime = System.currentTimeMillis() + 10000;
do {
try {
Registry reg = LocateRegistry.getRegistry("127.0.0.1", port);
long stopTime = System.currentTimeMillis() + DEFAULT_TIMEOUT_MS;
do {
try {
remote = (ClipboardCommands) reg.lookup(ClipboardCommands.ID);
break;
} catch (NotBoundException e) {
// try again because the remote app probably hasn't bound yet
}
} while (System.currentTimeMillis() < stopTime);
} catch (RemoteException e) {

Integer exitValue = null;
boolean waitFor = false;
try {
remote = (ClipboardCommands) reg.lookup(ClipboardCommands.ID);
break;
} catch (NotBoundException e) {
// try again because the remote app probably hasn't bound yet
waitFor = remoteClipboardProcess.waitFor(5, TimeUnit.SECONDS);
if (waitFor) {
exitValue = remoteClipboardProcess.exitValue();
}
} catch (InterruptedException e1) {
Thread.interrupted();
}
} while (System.currentTimeMillis() < stopTime);

String message = "Failed to get remote clipboards command, this seems to happen on macOS on I-build tests. Exception: "
+ e.toString() + " waitFor: " + waitFor + " exitValue: " + exitValue;

// Give some diagnostic information to help track down why this fails on build
// machine. We only hard error on Linux, for other platforms we allow test to
// just be skipped until we track down what is causing
// https://github.com/eclipse-platform/eclipse.platform.swt/issues/2553
assumeTrue(SwtTestUtil.isGTK, message);
throw new RuntimeException(message, e);
}
assertNotNull(remote);

// Run a no-op on the Swing event loop so that we know it is idle
Expand Down Expand Up @@ -318,7 +345,7 @@ public interface ExceptionalSupplier<T> {
* the thread completes, or until a timeout is reached.
*/
private <T> T runOperationInThread(ExceptionalSupplier<T> supplier) throws RuntimeException {
return runOperationInThread(2000, supplier);
return runOperationInThread(DEFAULT_TIMEOUT_MS, supplier);
}

/**
Expand Down
Loading