Skip to content

Commit b74ecaa

Browse files
committed
Make o.e.test Screenshots work when Platform is not there
Needed by SWT tests screenshoting.
1 parent 9854ee5 commit b74ecaa

File tree

1 file changed

+17
-8
lines changed
  • eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test

1 file changed

+17
-8
lines changed

eclipse.platform.releng/bundles/org.eclipse.test/src/org/eclipse/test/Screenshots.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2016 IBM Corporation and others.
2+
* Copyright (c) 2016, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -124,13 +124,22 @@ public static File getResultsDirectory() {
124124
}
125125

126126
private static File getJunitReportOutput() {
127-
String[] args = Platform.getCommandLineArgs();
128-
for (int i = 0; i < args.length - 1; i++) {
129-
if ("-junitReportOutput".equals(args[i])) { // see library.xml and org.eclipse.test.EclipseTestRunner
130-
return new File(args[i + 1]).getAbsoluteFile();
131-
}
132-
}
133-
return null;
127+
boolean platformAvailable = false;
128+
try {
129+
Class.forName("org.eclipse.core.runtime.Platform", false, Screenshots.class.getClassLoader());
130+
platformAvailable = true;
131+
} catch (ClassNotFoundException e) {
132+
platformAvailable = false;
133+
}
134+
if (platformAvailable) {
135+
String[] args = Platform.getCommandLineArgs();
136+
for (int i = 0; i < args.length - 1; i++) {
137+
if ("-junitReportOutput".equals(args[i])) { // see library.xml and org.eclipse.test.EclipseTestRunner
138+
return new File(args[i + 1]).getAbsoluteFile();
139+
}
140+
}
141+
}
142+
return null;
134143
}
135144

136145
/**

0 commit comments

Comments
 (0)