|
15 | 15 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
16 | 16 | import static org.junit.jupiter.api.Assertions.assertNull; |
17 | 17 | import static org.junit.jupiter.api.Assertions.assertTrue; |
| 18 | +import static org.junit.jupiter.api.Assumptions.assumeTrue; |
18 | 19 |
|
19 | 20 | import java.io.BufferedReader; |
20 | 21 | import java.io.InputStreamReader; |
21 | 22 | import java.lang.ProcessBuilder.Redirect; |
22 | 23 | import java.nio.file.Files; |
23 | 24 | import java.nio.file.Path; |
24 | 25 | import java.rmi.NotBoundException; |
| 26 | +import java.rmi.RemoteException; |
25 | 27 | import java.rmi.registry.LocateRegistry; |
26 | 28 | import java.rmi.registry.Registry; |
27 | 29 | import java.util.List; |
@@ -168,16 +170,40 @@ private void startRemoteClipboardCommands() throws Exception { |
168 | 170 | throw new RuntimeException("Failed to get port"); |
169 | 171 | }); |
170 | 172 | 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; |
174 | 188 | 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(); |
179 | 195 | } |
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 | + } |
181 | 207 | assertNotNull(remote); |
182 | 208 |
|
183 | 209 | // Run a no-op on the Swing event loop so that we know it is idle |
|
0 commit comments