Skip to content

Commit f746154

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 4a201e2 commit f746154

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

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

+21-6
Original file line numberDiff line numberDiff line change
@@ -2847,12 +2847,11 @@ private static Set<Entry<String, String>> getPropertiesSafe() {
28472847
private static List<String> getOpenedDescriptors() {
28482848
List<String> paths = new ArrayList<>();
28492849
Path fd = Paths.get("/proc/self/fd/");
2850-
try(DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd)){
2851-
directoryStream.forEach(f -> {
2852-
try {
2853-
paths.add(Files.isSymbolicLink(f)? Files.readSymbolicLink(f).toString() : f.toString());
2854-
} catch (IOException e) {
2855-
e.printStackTrace();
2850+
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(fd)) {
2851+
directoryStream.forEach(path -> {
2852+
String resolvedPath = resolveSymLink(path);
2853+
if (isTestRelatedFileDescriptor(resolvedPath)) {
2854+
paths.add(resolvedPath);
28562855
}
28572856
});
28582857
} catch (IOException e1) {
@@ -2865,6 +2864,22 @@ private static List<String> getOpenedDescriptors() {
28652864
return paths;
28662865
}
28672866

2867+
private static boolean isTestRelatedFileDescriptor(String fileDescriptorPath) {
2868+
// Do not consider file descriptors of Maven artifacts that are currently opened
2869+
// by other Maven plugins executed in parallel build (such as parallel
2870+
// compilation of the swt.tools bundle etc.)
2871+
return fileDescriptorPath != null && !fileDescriptorPath.contains(".m2")
2872+
&& !fileDescriptorPath.contains("target/classes");
2873+
}
2874+
2875+
private static String resolveSymLink(Path path) {
2876+
try {
2877+
return Files.isSymbolicLink(path) ? Files.readSymbolicLink(path).toString() : path.toString();
2878+
} catch (IOException e) {
2879+
e.printStackTrace();
2880+
}
2881+
return null;
2882+
}
28682883

28692884
private static void processUiEvents() {
28702885
Display display = Display.getCurrent();

0 commit comments

Comments
 (0)