From bbb5710b32a8e6190e3d93a263a70cd66090bd5f Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 5 Sep 2017 09:42:19 +0200 Subject: [PATCH] don't spawn gazillions of threads in tests --- .../intellij/openapi/application/impl/LaterInvocatorTest.java | 2 +- .../openapi/fileEditor/impl/FileDocumentManagerImplTest.java | 4 ++-- .../testSrc/com/intellij/psi/util/CachedValuesTest.groovy | 2 +- .../tests/com/intellij/util/xml/DomIncludesTest.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java index 8b6ef4a4a574..5ae6dbd18949 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/application/impl/LaterInvocatorTest.java @@ -598,7 +598,7 @@ public class LaterInvocatorTest extends PlatformTestCase { public void testDispatchInvocationEventsVsInvokeLaterFromBgThreadRace() { Application app = ApplicationManager.getApplication(); app.invokeAndWait(() -> { - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 20; i++) { AtomicBoolean executed = new AtomicBoolean(); app.executeOnPooledThread(() -> app.invokeLater(EmptyRunnable.INSTANCE)); app.invokeLater(() -> executed.set(true)); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImplTest.java index 41238d243504..eb11f0c5560f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/impl/FileDocumentManagerImplTest.java @@ -663,8 +663,8 @@ public class FileDocumentManagerImplTest extends PlatformTestCase { List futures = new ArrayList<>(); for (VirtualFile file : files) { assertNull(fdm.getCachedDocument(file)); - for (int i = 0; i < 30; i++) { - futures.add(ApplicationManager.getApplication().executeOnPooledThread((Runnable)() -> ReadAction.run(() -> { + for (int i = 0; i < 2; i++) { + futures.add(ApplicationManager.getApplication().executeOnPooledThread(() -> ReadAction.run(() -> { Document document = fdm.getDocument(file); assertEquals(file, fdm.getFile(document)); }))); diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/CachedValuesTest.groovy b/platform/platform-tests/testSrc/com/intellij/psi/util/CachedValuesTest.groovy index 87ec7e688ee4..66a79dbcd416 100644 --- a/platform/platform-tests/testSrc/com/intellij/psi/util/CachedValuesTest.groovy +++ b/platform/platform-tests/testSrc/com/intellij/psi/util/CachedValuesTest.groovy @@ -63,7 +63,7 @@ class CachedValuesTest extends LightPlatformTestCase { calcCount.set(0) dependency.incModificationCount() - List jobs = (0..<10).collect { + List jobs = (0..<4).collect { ApplicationManager.application.executeOnPooledThread { for (i in 0..10) { assert 'result' == getCached() diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java index 95f8b1a000e8..237a82e10c08 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomIncludesTest.java @@ -100,7 +100,7 @@ public class DomIncludesTest extends LightCodeInsightFixtureTestCase { final PsiFile fileD = createFile("d.xml", textD); final String textE = ""; final PsiFile fileE = createFile("e.xml", textE); - final int threadCount = 100; + final int threadCount = 20; final int iterationCount = Timings.adjustAccordingToMySpeed(100, true); System.out.println("iterationCount = " + iterationCount);