Skip to content

Commit 47582ad

Browse files
committed
Browser tests: reduce timeout for instantiation to reasonable value
The timeout for browser instantiation in the browser tests has been increased to avoid flaky tests. However, browser instantiation taking that long is an indicator for something being wrong with the instantiation. There is no reason why instantiation may take that long during test execution but the same issue should never arise in productive use, thus such a case should be captured by tests and, if necessary, be fixed productively. In order to do so, this change reduces the test timeout value again to a more reasonable value. Since the first Edge browser instantiation takes rather long at least in the GitHub actions test environment, that instantiation is isolated in an execution before the test class. Related to #1676
1 parent 3e45b23 commit 47582ad

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,15 @@
102102
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
103103
public class Test_org_eclipse_swt_browser_Browser extends Test_org_eclipse_swt_widgets_Composite {
104104

105-
// TODO Reduce to reasonable value
106-
private static Duration MAXIMUM_BROWSER_CREATION_TIME = Duration.ofSeconds(90);
105+
private static Duration MAXIMUM_BROWSER_CREATION_TIME = Duration.ofSeconds(10);
107106

108107
static {
109108
try {
110109
printSystemEnv();
111110
} catch (Exception e) {
112111
e.printStackTrace();
113112
}
114-
System.setProperty("org.eclipse.swt.internal.win32.Edge.timeout", Long.toString(MAXIMUM_BROWSER_CREATION_TIME.toMillis()));
113+
System.setProperty("org.eclipse.swt.internal.win32.Edge.timeout", Long.toString(Duration.ofSeconds(90).toMillis()));
115114
}
116115

117116
// CONFIG
@@ -165,10 +164,11 @@ public Test_org_eclipse_swt_browser_Browser(int swtBrowserSettings) {
165164

166165
@BeforeClass
167166
public static void setupEdgeEnvironment() {
168-
// initialize Edge environment before any test runs to isolate environment setup
167+
// Initialize Edge environment before any test runs to isolate environment setup
168+
// as this takes quite long in GitHub Actions builds
169169
if (SwtTestUtil.isWindows) {
170170
Shell shell = new Shell();
171-
new Browser(shell, SWT.EDGE);
171+
new Browser(shell, SWT.EDGE).getUrl();
172172
shell.dispose();
173173
}
174174
}
@@ -2846,7 +2846,12 @@ private static List<String> getOpenedDescriptors() {
28462846
try(DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd)){
28472847
directoryStream.forEach(f -> {
28482848
try {
2849-
paths.add(Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString());
2849+
// Do not consider file descriptors of Maven artifacts that are currently opened by other Maven
2850+
// plugins executed in parallel build (such as parallel compilation of the swt.tools bundle etc.)
2851+
String resolvedPath = Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString();
2852+
if (!resolvedPath.contains(".m2")) {
2853+
paths.add(resolvedPath);
2854+
}
28502855
} catch (IOException e) {
28512856
e.printStackTrace();
28522857
}

tests/org.eclipse.swt.tests/build.properties

+9
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ bin.includes = .,\
2323
META-INF/
2424

2525
bin.excludes = ManualTests/
26+
27+
# The following dependency prevents parallel build of this and other bundles.
28+
# Browser tests highly depend on system state and thus become flaky when other bundles
29+
# are built in parallel.
30+
additional.bundles = org.eclipse.swt.tools,\
31+
org.eclipse.swt.examples,\
32+
org.eclipse.swt.examples.browser.demos,\
33+
org.eclipse.swt.examples.launcher,\
34+
org.eclipse.swt.examples.views

0 commit comments

Comments
 (0)