Skip to content

Commit 2d908c9

Browse files
committed
[Linux] Fix random test failures of browser tests #1523
Browser tests randomly fail during Jenkins execution because of too many opened file descriptors. The reason seems to be that the build uses parallel execution and Maven plugins executed for other bundles may have opened and closed file descriptors in parallel, which are erroneously taken into account by the browser tests evaluating the number of file descriptors left open after a test execution. This change excludes open file descriptors for Maven artifacts used in parallel by other Maven plugins by not considering file descriptors with their path containing ".m2" or "target/classes". Fixes #1523
1 parent cfbd282 commit 2d908c9

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,14 +2843,8 @@ private static Set<Entry<String, String>> getPropertiesSafe() {
28432843
private static List<String> getOpenedDescriptors() {
28442844
List<String> paths = new ArrayList<>();
28452845
Path fd = Paths.get("/proc/self/fd/");
2846-
try(DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd)){
2847-
directoryStream.forEach(f -> {
2848-
try {
2849-
paths.add(Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString());
2850-
} catch (IOException e) {
2851-
e.printStackTrace();
2852-
}
2853-
});
2846+
try(DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd, path -> isTestRelatedFileDescriptor(path))) {
2847+
directoryStream.forEach(path-> paths.add(resolveSymLink(path)));
28542848
} catch (IOException e1) {
28552849
e1.printStackTrace();
28562850
}
@@ -2862,6 +2856,23 @@ private static List<String> getOpenedDescriptors() {
28622856
}
28632857

28642858

2859+
private static boolean isTestRelatedFileDescriptor(Path fileDescriptorPath) {
2860+
// Do not consider file descriptors of Maven artifacts that are currently opened
2861+
// by other Maven plugins executed in parallel build (such as parallel
2862+
// compilation of the swt.tools bundle etc.)
2863+
String resolvedPath = resolveSymLink(fileDescriptorPath);
2864+
return resolvedPath != null && !resolvedPath.contains(".m2") && !resolvedPath.contains("target/classes");
2865+
}
2866+
2867+
private static String resolveSymLink(Path path) {
2868+
try {
2869+
return Files.isSymbolicLink(path) ? Files.readSymbolicLink(path).toString() : path.toString();
2870+
} catch (IOException e) {
2871+
e.printStackTrace();
2872+
}
2873+
return null;
2874+
}
2875+
28652876
private static void processUiEvents() {
28662877
Display display = Display.getCurrent();
28672878
while (display != null && !display.isDisposed() && display.readAndDispatch()) {

0 commit comments

Comments
 (0)