Skip to content

Commit

Permalink
[performance] AbstractJavaModelTests: avoid needless sleep
Browse files Browse the repository at this point in the history
getJavaModel().getJavaProjects() will never return the just created
project when inside a workspace operation.

JavaSearchScopeTests 39s -> 34s

removes also repeated logging
"Aborted waitForAutoBuild() because running with the workspace rule"
  • Loading branch information
jukzi committed Jan 7, 2025
1 parent 0c40693 commit bb30325
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2324,21 +2324,21 @@ public void run(IProgressMonitor monitor) throws CoreException {
IProject sameProject = getWorkspaceRoot().getProject(projectName);
assertEquals("Returned project doesn't match same project from workspace: " + sameProject + " vs " + project, sameProject, project);

List<IJavaProject> javaProjects = List.of(getJavaModel().getJavaProjects());
boolean foundInModel = javaProjects.stream().anyMatch(p -> projectName.equals(p.getElementName()));
if (!foundInModel) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
waitForAutoBuild();
waitForManualRefresh();
javaProjects = List.of(getJavaModel().getJavaProjects());
foundInModel = javaProjects.stream().anyMatch(p -> projectName.equals(p.getElementName()));
}
boolean isNestedWorkspaceCall = isWorkspaceRuleAlreadyInUse(getWorkspaceRoot());
if (!isNestedWorkspaceCall) {
List<IJavaProject> javaProjects = List.of(getJavaModel().getJavaProjects());
boolean foundInModel = javaProjects.stream().anyMatch(p -> projectName.equals(p.getElementName()));
if (!foundInModel) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
waitForAutoBuild();
waitForManualRefresh();
javaProjects = List.of(getJavaModel().getJavaProjects());
foundInModel = javaProjects.stream().anyMatch(p -> projectName.equals(p.getElementName()));
}
assertTrue("Project '" + projectName + "' should be present in JavaModel, but we found only: " + javaProjects, foundInModel);
} else {
// No assert here, caller has to check it *after* the workspace task
Expand Down

0 comments on commit bb30325

Please sign in to comment.