Skip to content

Commit 6b340ef

Browse files
committed
Resources / Runtime tests: Do not depend on higher-level plug-ins.
* PreferencesServiceTest is not deterministic but its behavior changes depending on the presence of downstream plug-in org.eclipse.core.resources. Take this into account. * IResourceTest should not depend on downstream plug-in org.eclipse.ui.ide (even inside a downstream repository). Use a different (upstream) filter provider in the unit test instead. These downstream plug-ins are currently only visible because Tycho adds the full-blown UI test harness to the target platform unconditionally, even if there is no such actual dependency [1]. This is a cleanup in preparation for [2]. [1] eclipse-tycho/tycho#5349 [2] eclipse-tycho/tycho#5362
1 parent a6bd13c commit 6b340ef

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/IResourceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,9 @@ private IProject createProject(boolean applyResFilter) throws CoreException {
11011101
sourceProj.open(createTestMonitor());
11021102
// create a new filter.
11031103
if (applyResFilter) {
1104-
String MULTI_FILT_ID = "org.eclipse.ui.ide.multiFilter";
1105-
String FILT_ARG = "1.0-length-equals-false-false-10485760";
1106-
FileInfoMatcherDescription filterDesc = new FileInfoMatcherDescription(MULTI_FILT_ID, FILT_ARG);
1104+
String filterProviderId = "org.eclipse.core.resources.regexFilterMatcher";
1105+
String filterArguments = "foo.*";
1106+
FileInfoMatcherDescription filterDesc = new FileInfoMatcherDescription(filterProviderId, filterArguments);
11071107
int EXCL_FILE_GT = IResourceFilterDescription.EXCLUDE_ALL + IResourceFilterDescription.FILES
11081108
+ IResourceFilterDescription.INHERITABLE;
11091109
sourceProj.createFilter(EXCL_FILE_GT, filterDesc, IResource.BACKGROUND_REFRESH, createTestMonitor());

runtime/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/PreferencesServiceTest.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
import org.junit.jupiter.api.AfterEach;
6161
import org.junit.jupiter.api.Disabled;
6262
import org.junit.jupiter.api.Test;
63+
import org.osgi.framework.Bundle;
6364
import org.osgi.service.prefs.BackingStoreException;
6465
import org.osgi.service.prefs.Preferences;
6566

@@ -222,11 +223,25 @@ public void testImportExportBasic() throws Exception {
222223
@Test
223224
public void testLookupOrder() {
224225
IPreferencesService service = Platform.getPreferencesService();
225-
String[] defaultOrder = new String[] {"project", //$NON-NLS-1$
226+
List<String> defaultOrderList = new ArrayList<>(List.of( //
226227
InstanceScope.SCOPE, //
227228
ConfigurationScope.SCOPE, //
228229
UserScope.SCOPE, //
229-
DefaultScope.SCOPE};
230+
DefaultScope.SCOPE) //
231+
);
232+
Bundle resourcesBundle = Platform.getBundle("org.eclipse.core.resources");
233+
if (resourcesBundle != null) {
234+
if (resourcesBundle.getState() == Bundle.ACTIVE) {
235+
// "project" scope is added via
236+
// PreferencesService.prependScopeToDefaultDefaultLookupOrder(String)
237+
// by org.eclipse.core.internal.resources.Workspace, when the
238+
// org.eclipse.core.resources bundle is started, which depends on
239+
// the test execution environment (is the UI harness part of the
240+
// launch?)
241+
defaultOrderList.add(0, "project");
242+
}
243+
}
244+
String[] defaultOrder = defaultOrderList.toArray(String[]::new);
230245
String[] fullOrder = new String[] {"a", "b", "c"};
231246
String[] nullKeyOrder = new String[] {"e", "f", "g"};
232247
String qualifier = getUniqueString();

0 commit comments

Comments
 (0)