diff options
author | Michael Keppler | 2019-01-01 19:06:20 +0000 |
---|---|---|
committer | Michael Keppler | 2019-02-05 07:52:25 +0000 |
commit | cec8d1ecbf46ab0dd5d3612a8c02e877a154d919 (patch) | |
tree | 3d7340ec4ccf201a9422a564f3d522738b72b940 /org.eclipse.egit.core.test | |
parent | 83d739c1308dcc5647503ad0153d3ca4b0386ac5 (diff) | |
download | egit-cec8d1ecbf46ab0dd5d3612a8c02e877a154d919.tar.gz egit-cec8d1ecbf46ab0dd5d3612a8c02e877a154d919.tar.xz egit-cec8d1ecbf46ab0dd5d3612a8c02e877a154d919.zip |
Avoid jobs still running at test shutdown
Sometimes during tests we have jobs still running. Recent example is
https://ci.eclipse.org/egit/job/egit/4991/consoleFull (search for
"following jobs"). Therefore increase the timeout from 5 to 10 seconds.
10 seconds have already been used at other places in our tests, and they
avoided the message for me locally when experimenting with different
values. Since the log output occurs seldom, the increase in test runtime
can be ignored (in most cases there will not be any increase).
Also correct a Javadoc in that area, and inline one other method (to
avoid one more duplication of wrong Javadoc).
Change-Id: I14b16d33e493cc9d4a7fe833b1fd29a42f4822b5
Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r-- | org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java index 319aa32296..27d6caba55 100644 --- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java +++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/indexdiff/IndexDiffCacheEntryTest.java @@ -37,7 +37,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { // trigger reload if more than one file is changed private static final int MAX_FILES_FOR_UPDATE = 1; - private static final int MAX_WAIT_TIME = 10 * 1000; + private static final long MAX_WAIT_TIME = 10 * 1000; private TestRepository testRepository; @@ -51,7 +51,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { prepareCacheEntry(); entry.refresh(); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // on refresh, full reload is triggered assertTrue(entry.reloadScheduled); @@ -59,7 +59,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { cleanEntryFlags(); entry.refreshFiles(Arrays.asList("a")); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // one single file: no reload assertFalse(entry.reloadScheduled); @@ -67,7 +67,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { cleanEntryFlags(); entry.refreshFiles(Arrays.asList("a", "b")); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // two files: update is triggered, but decides to run full reload assertTrue(entry.reloadScheduled); @@ -76,7 +76,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { entry.getUpdateJob().addChanges(Arrays.asList("a", "b"), Collections.<IResource> emptyList()); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // two files: update is not triggered (we call through the job directly) // but this calls full reload @@ -90,7 +90,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { prepareCacheEntry(); testRepository.connect(project.project); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // Should have something from the project String projectName = project.project.getName(); @@ -98,7 +98,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { entry.getIndexDiff().getUntracked(), projectName + '/')); project.project.delete(true, null); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); assertFalse(containsItemsStartingWith( entry.getIndexDiff().getUntracked(), projectName + '/')); } @@ -108,7 +108,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { prepareCacheEntry(); testRepository.connect(project.project); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // on a simple connect, nothing should be called assertFalse(entry.reloadScheduled); @@ -118,14 +118,14 @@ public class IndexDiffCacheEntryTest extends GitTestCase { // adds .project and .classpath files: more than limit of 1, // so update redirects to reload testRepository.addToIndex(project.project); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); assertTrue(entry.reloadScheduled); assertTrue(entry.updateScheduled); cleanEntryFlags(); testRepository.createInitialCommit("first commit\n"); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // RefsChangedEvent causes always full update assertTrue(entry.reloadScheduled); @@ -145,7 +145,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { } }, null); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // adds 2 files: more than limit of 1, // so update redirects to reload @@ -164,7 +164,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { } }, null); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // adds 1 file: less than limit of 1, so no reload assertFalse(entry.reloadScheduled); @@ -182,7 +182,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { } }, null); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // adds .gitignore file: always full reload assertTrue(entry.reloadScheduled); @@ -190,18 +190,6 @@ public class IndexDiffCacheEntryTest extends GitTestCase { cleanEntryFlags(); } - /** - * Waits at least 50 milliseconds until no jobs of given family are running - * - * @param maxWaitTime - * @param family - * @throws InterruptedException - */ - private void waitForJobs(long maxWaitTime, Object family) - throws InterruptedException { - TestUtils.waitForJobs(maxWaitTime, family); - } - private void cleanEntryFlags() { entry.reloadScheduled = false; entry.updateScheduled = false; @@ -209,7 +197,7 @@ public class IndexDiffCacheEntryTest extends GitTestCase { private IndexDiffCacheEntry2 prepareCacheEntry() throws Exception { entry = new IndexDiffCacheEntry2(repository); - waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); + TestUtils.waitForJobs(MAX_WAIT_TIME, JobFamilies.INDEX_DIFF_CACHE_UPDATE); // on creation, full reload is triggered assertTrue(entry.reloadScheduled); |