Skip to content

Commit ad4e4cc

Browse files
committed
Add diagnostics to failing Clipboard test and skip on non-GTK
This records additional information about the state of the remote process. This will only hard fail on Linux as we have seen test pass on Linux, and Linux is the primary target as the Clipboard is under development on Linux only now for GTK4 work. Part of #2553
1 parent 00106b4 commit ad4e4cc

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_dnd_Clipboard.java

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
import static org.junit.jupiter.api.Assertions.assertNotNull;
1616
import static org.junit.jupiter.api.Assertions.assertNull;
1717
import static org.junit.jupiter.api.Assertions.assertTrue;
18+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
1819

1920
import java.io.BufferedReader;
2021
import java.io.InputStreamReader;
2122
import java.lang.ProcessBuilder.Redirect;
2223
import java.nio.file.Files;
2324
import java.nio.file.Path;
2425
import java.rmi.NotBoundException;
26+
import java.rmi.RemoteException;
2527
import java.rmi.registry.LocateRegistry;
2628
import java.rmi.registry.Registry;
2729
import java.util.List;
@@ -168,16 +170,40 @@ private void startRemoteClipboardCommands() throws Exception {
168170
throw new RuntimeException("Failed to get port");
169171
});
170172
assertNotEquals(0, port);
171-
Registry reg = LocateRegistry.getRegistry("127.0.0.1", port);
172-
long stopTime = System.currentTimeMillis() + 10000;
173-
do {
173+
try {
174+
Registry reg = LocateRegistry.getRegistry("127.0.0.1", port);
175+
long stopTime = System.currentTimeMillis() + 10000;
176+
do {
177+
try {
178+
remote = (ClipboardCommands) reg.lookup(ClipboardCommands.ID);
179+
break;
180+
} catch (NotBoundException e) {
181+
// try again because the remote app probably hasn't bound yet
182+
}
183+
} while (System.currentTimeMillis() < stopTime);
184+
} catch (RemoteException e) {
185+
186+
Integer exitValue = null;
187+
boolean waitFor = false;
174188
try {
175-
remote = (ClipboardCommands) reg.lookup(ClipboardCommands.ID);
176-
break;
177-
} catch (NotBoundException e) {
178-
// try again because the remote app probably hasn't bound yet
189+
waitFor = remoteClipboardProcess.waitFor(5, TimeUnit.SECONDS);
190+
if (waitFor) {
191+
exitValue = remoteClipboardProcess.exitValue();
192+
}
193+
} catch (InterruptedException e1) {
194+
Thread.interrupted();
179195
}
180-
} while (System.currentTimeMillis() < stopTime);
196+
197+
String message = "Failed to get remote clipboards command, this seems to happen on macOS on I-build tests. Exception: "
198+
+ e.toString() + " waitFor: " + waitFor + " exitValue: " + exitValue;
199+
200+
// Give some diagnostic information to help track down why this fails on build
201+
// machine. We only hard error on Linux, for other platforms we allow test to
202+
// just be skipped until we track down what is causing
203+
// https://github.com/eclipse-platform/eclipse.platform.swt/issues/2553
204+
assumeTrue(SwtTestUtil.isGTK, message);
205+
throw new RuntimeException(message, e);
206+
}
181207
assertNotNull(remote);
182208

183209
// Run a no-op on the Swing event loop so that we know it is idle

0 commit comments

Comments
 (0)