Skip to content

Commit 0222db7

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 cfbd282 commit 0222db7

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

+4
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,11 @@ private static void processOSMessagesUntil(Supplier<Boolean> condition, Display
463463
AtomicBoolean timeoutOccurred = new AtomicBoolean();
464464
// The timer call also wakes up the display to avoid being stuck in display.sleep()
465465
display.timerExec((int) MAXIMUM_OPERATION_TIME.toMillis(), () -> timeoutOccurred.set(true));
466+
long last = System.currentTimeMillis();
466467
while (!display.isDisposed() && !condition.get() && !timeoutOccurred.get()) {
468+
if (System.currentTimeMillis() - last > 100) {
469+
System.out.println("DEBUG: Waiting for instantiation: " + System.currentTimeMillis());
470+
}
467471
if (OS.PeekMessage(msg, 0, 0, 0, OS.PM_NOREMOVE)) {
468472
display.readAndDispatch();
469473
} else {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.junit.runners.Suite;
2222

2323
@RunWith(TracingSuite.class)
24-
@TracingOptions(stackDumpTimeoutSeconds = 60)
24+
@TracingOptions(stackDumpTimeoutSeconds = 120)
2525
@Suite.SuiteClasses({
2626
Test_org_eclipse_swt_browser_Browser.class,
2727
})

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

+12-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,11 +164,13 @@ 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();
173+
processUiEvents();
173174
}
174175
}
175176

@@ -2846,7 +2847,12 @@ private static List<String> getOpenedDescriptors() {
28462847
try(DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd)){
28472848
directoryStream.forEach(f -> {
28482849
try {
2849-
paths.add(Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString());
2850+
// Do not consider file descriptors of Maven artifacts that are currently opened by other Maven
2851+
// plugins executed in parallel build (such as parallel compilation of the swt.tools bundle etc.)
2852+
String resolvedPath = Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString();
2853+
if (!resolvedPath.contains(".m2")) {
2854+
paths.add(resolvedPath);
2855+
}
28502856
} catch (IOException e) {
28512857
e.printStackTrace();
28522858
}

0 commit comments

Comments
 (0)