Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hurricup/flaky integration tests #2874

Merged
merged 2 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .idea/runConfigurations/Test_Plugin__Docker_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.jetbrains.annotations.TestOnly;

import java.util.*;
import com.intellij.util.concurrency.Semaphore;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BooleanSupplier;

Expand All @@ -56,6 +57,7 @@ public class MojoProjectManager implements Disposable {
private final @NotNull MergingUpdateQueue myUpdateQueue;
private final @NotNull AtomicBoolean myUpdatingModel = new AtomicBoolean(false);
private volatile @NotNull Model myModel = new Model(Collections.emptySet());
private volatile Semaphore myTestSemaphore;

public MojoProjectManager(@NotNull Project project) {
myProject = project;
Expand Down Expand Up @@ -140,7 +142,16 @@ private void updateModel() {
scheduleUpdate();
}
else {
doUpdateModel();
try{
LOG.debug("Performing model update");
doUpdateModel();
}
finally {
if( myTestSemaphore != null) {
myTestSemaphore.up();
myTestSemaphore = null;
}
}
}
});
}
Expand Down Expand Up @@ -281,7 +292,9 @@ private Set<MojoProject> getProjects() {

@TestOnly
public BooleanSupplier updateInTestMode() {
var semaphore = new Semaphore(1);
myTestSemaphore = semaphore;
updateModel();
return ()-> myUpdateQueue.isEmpty() && !myUpdatingModel.get();
return semaphore::isUp;
}
}
Loading