3131import org .eclipse .debug .core .DebugPlugin ;
3232import org .eclipse .debug .core .ILaunch ;
3333import org .eclipse .debug .core .ILaunchManager ;
34+ import org .eclipse .debug .internal .ui .views .console .ProcessConsole ;
3435import org .eclipse .jdt .debug .testplugin .JavaTestPlugin ;
36+ import org .eclipse .jface .text .reconciler .AbstractReconciler ;
3537import org .eclipse .swt .widgets .Display ;
3638import org .junit .Assert ;
3739
@@ -110,6 +112,8 @@ public static void runEventLoop() {
110112 /**
111113 * Utility for waiting until the execution of jobs of any family has finished or timeout is reached. If no jobs are running, the method waits
112114 * given minimum wait time. While this method is waiting for jobs, UI events are processed.
115+ * <p>
116+ * <b>Note:</b> This method does not wait for jobs that belong to the families specified in {@link #getUsualJobFamiliesToIgnore()}.
113117 *
114118 * @param owner
115119 * name of the caller which will be logged as prefix if the wait times out
@@ -120,7 +124,7 @@ public static void runEventLoop() {
120124 * @return true if the method timed out, false if all the jobs terminated before the timeout
121125 */
122126 public static boolean waitForJobs (String owner , long minTimeMs , long maxTimeMs ) {
123- return waitForJobs (owner , minTimeMs , maxTimeMs , ( Object []) null );
127+ return waitForJobs (owner , minTimeMs , maxTimeMs , getUsualJobFamiliesToIgnore () );
124128 }
125129
126130 /**
@@ -146,6 +150,15 @@ public static boolean waitForJobs(String owner, Object jobFamily, long minTimeMs
146150 if (maxTimeMs < minTimeMs ) {
147151 throw new IllegalArgumentException ("Max time is smaller as min time!" );
148152 }
153+ // Not so nice workaround for https://github.com/eclipse-jdt/eclipse.jdt.debug/issues/721
154+ // After https://github.com/eclipse-platform/eclipse.platform.ui/pull/3025 every opened editor
155+ // means there will be a reconciler job running, which is not what we do NOT want to wait for.
156+ // AbstractReconciler.class is the family object we can check for.
157+ if (excludedFamilies == null ) {
158+ excludedFamilies = new Object [] { AbstractReconciler .class };
159+ } else if (excludedFamilies .length == 1 && excludedFamilies [0 ] == ProcessConsole .class ) {
160+ excludedFamilies = getUsualJobFamiliesToIgnore ();
161+ }
149162 wakeUpSleepingJobs (jobFamily );
150163 final long startNanos = System .nanoTime ();
151164 while (System .nanoTime () - startNanos < minTimeMs * 1_000_000L ) {
@@ -185,6 +198,18 @@ public static boolean waitForJobs(String owner, Object jobFamily, long minTimeMs
185198 return false ;
186199 }
187200
201+ /**
202+ * Returns a list of job families that are usually ignored in tests.
203+ * <p>
204+ * This is used to avoid waiting for jobs that are not relevant to the test.
205+ * </p>
206+ *
207+ * @return an array of job family classes to ignore
208+ */
209+ public static Object [] getUsualJobFamiliesToIgnore () {
210+ return new Object [] { ProcessConsole .class , AbstractReconciler .class };
211+ }
212+
188213 private static void wakeUpSleepingJobs (Object family ) {
189214 List <Job > sleepingJobs = getSleepingJobs (family );
190215 for (Job job : sleepingJobs ) {
0 commit comments