Skip to content

Commit

Permalink
OpenFromClipboardTests: wait for job families instead of excluding #442
Browse files Browse the repository at this point in the history
  • Loading branch information
EcljpseB0T committed Dec 3, 2024
1 parent a9a5f80 commit 3cf918f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ public static boolean waitForJobs(String owner, long minTimeMs, long maxTimeMs)
* @return true if the method timed out, false if all the jobs terminated before the timeout
*/
public static boolean waitForJobs(String owner, long minTimeMs, long maxTimeMs, Object... excludedFamilies) {
return waitForJobs(owner, null, minTimeMs, maxTimeMs, excludedFamilies);
}

public static boolean waitForJobs(String owner, Object jobFamily, long minTimeMs, long maxTimeMs, Object... excludedFamilies) {
if (maxTimeMs < minTimeMs) {
throw new IllegalArgumentException("Max time is smaller as min time!");
}
wakeUpSleepingJobs(null);
wakeUpSleepingJobs(jobFamily);
final long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < minTimeMs) {
runEventLoop();
Expand All @@ -153,7 +157,7 @@ public static boolean waitForJobs(String owner, long minTimeMs, long maxTimeMs,
} catch (InterruptedException e) {
// Uninterruptable
}
List<Job> jobs = getRunningOrWaitingJobs(null, excludedFamilies);
List<Job> jobs = getRunningOrWaitingJobs(jobFamily, excludedFamilies);
if (jobs.isEmpty()) {
// only uninteresting jobs running
break;
Expand All @@ -169,7 +173,7 @@ public static boolean waitForJobs(String owner, long minTimeMs, long maxTimeMs,
dumpRunningOrWaitingJobs(owner, jobs);
return true;
}
wakeUpSleepingJobs(null);
wakeUpSleepingJobs(jobFamily);
}
runningJobs.clear();
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public static void tearDownClass() throws CoreException {
}

private static void waitForEncodingRelatedJobs() {
TestUtil.waitForJobs("OpenFromClipboardTests", 10, 5_000, ValidateProjectEncoding.class);
TestUtil.waitForJobs("OpenFromClipboardTests", 10, 5_000, CharsetDeltaJob.FAMILY_CHARSET_DELTA);
TestUtil.waitForJobs("OpenFromClipboardTests", ValidateProjectEncoding.class, 0, 5_000);
TestUtil.waitForJobs("OpenFromClipboardTests", CharsetDeltaJob.FAMILY_CHARSET_DELTA, 0, 5_000);
}

private static IJavaProject createProject(String name) throws CoreException {
Expand Down

0 comments on commit 3cf918f

Please sign in to comment.