Skip to content

Commit c8dfaf3

Browse files
committed
Minor clean-ups and simplifications in TestResultsGenerator
1 parent e31a3a2 commit c8dfaf3

File tree

2 files changed

+12
-31
lines changed

2 files changed

+12
-31
lines changed

bundles/org.eclipse.build.tools/META-INF/MANIFEST.MF

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Bundle-Localization: plugin
77
Bundle-ActivationPolicy: lazy
88
Bundle-RequiredExecutionEnvironment: JavaSE-21
99
Require-Bundle: org.apache.ant,
10-
org.eclipse.osgi,
1110
org.eclipse.core.runtime;bundle-version="3.29.0"
1211
Bundle-ClassPath: buildTools.jar
1312
Bundle-Vendor: %Bundle-Vendor

bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/TestResultsGenerator.java

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
import java.io.FilenameFilter;
1919
import java.io.IOException;
2020
import java.io.Writer;
21+
import java.nio.charset.Charset;
2122
import java.nio.file.Files;
23+
import java.nio.file.Path;
2224
import java.util.ArrayList;
2325
import java.util.Arrays;
2426
import java.util.Collections;
@@ -109,22 +111,17 @@ private Row getRow(String rowname) {
109111
}
110112

111113
public Cell getCell(String rowName, String columnName) {
112-
Cell result = getRow(rowName).getCell(columnName);
113-
return result;
114+
return getRow(rowName).getCell(columnName);
114115
}
115116

116117
public int getCellErrorCount(String rowName, String columnName) {
117-
int result = -1;
118118
Cell cell = getRow(rowName).getCell(columnName);
119-
result = cell.getErrorCount();
120-
return result;
119+
return cell.getErrorCount();
121120
}
122121

123122
public File getCellResultsFile(String rowName, String columnName) {
124-
File result = null;
125123
Cell cell = getRow(rowName).getCell(columnName);
126-
result = cell.getResultsFile();
127-
return result;
124+
return cell.getResultsFile();
128125
}
129126

130127
public void putCell(String rowName, String columnName, Integer cellValue, File file) {
@@ -263,11 +260,6 @@ private void logException(final Throwable e) {
263260
}
264261
}
265262

266-
private static byte[] getFileByteContent(final String fileName) throws IOException {
267-
final File file = new File(fileName);
268-
return Files.readAllBytes(file.toPath());
269-
}
270-
271263
// Configuration of test machines.
272264
// Add or change new configurations here
273265
// and update titles in testResults.template.php.
@@ -296,7 +288,7 @@ private static byte[] getFileByteContent(final String fileName) throws IOExcepti
296288
* 'isTested" is set) since the purpose is usually to include an additional
297289
* tested platform.
298290
*/
299-
private boolean regenerate = Boolean.FALSE;
291+
private boolean regenerate = false;
300292

301293
private int countCompileErrors(final String aString) {
302294
return extractNumber(aString, "error");
@@ -710,7 +702,6 @@ private void parseCompileLogs() throws IOException {
710702
+ ", was found to exist already and is being regenerated.");
711703
}
712704
log("DEBUG: BEGIN: Parsing compile logs and generating summary table.");
713-
String compileLogResults = "";
714705
final StringBuilder compilerString = new StringBuilder();
715706
final StringBuilder accessesString = new StringBuilder();
716707
processCompileLogsDirectory(getCompileLogsDirectoryName(), compilerString, accessesString);
@@ -722,7 +713,7 @@ private void parseCompileLogs() throws IOException {
722713
accessesString.append(
723714
"<tr><td class='namecell'>None</td><td class='cell'>&nbsp;</td><td class='cell'>&nbsp;</td></tr>" + EOL);
724715
}
725-
716+
String compileLogResults;
726717
compileLogResults = EOL + EOL + "<h3 id=\"PluginsErrors\">Plugins containing compile errors or warnings</h3>" + EOL
727718
+ EOL
728719
+ "<p>The table below shows the plugins in which errors or warnings were encountered. Click on the jar file link to view its"
@@ -774,9 +765,7 @@ private void parseJUnitTestsXml() throws IOException {
774765
foundConfigs.add(expectedConfig);
775766
// sort by name, for each 'config' found.
776767
Arrays.sort(xmlFileNamesForConfig);
777-
for (File file : xmlFileNamesForConfig) {
778-
allFileNames.add(file);
779-
}
768+
Collections.addAll(allFileNames, xmlFileNamesForConfig);
780769
}
781770
}
782771
File[] xmlFileNames = new File[allFileNames.size()];
@@ -1082,17 +1071,13 @@ private void readCompileLog(final String log, final StringBuilder compilerLog, f
10821071
}
10831072

10841073
private String readFile(final String fileName) {
1085-
byte[] aByteArray = null;
10861074
try {
1087-
aByteArray = getFileByteContent(fileName);
1075+
return Files.readString(Path.of(fileName), Charset.defaultCharset());
10881076
}
10891077
catch (final IOException e) {
10901078
logException(e);
1091-
}
1092-
if (aByteArray == null) {
10931079
return "";
10941080
}
1095-
return new String(aByteArray);
10961081
}
10971082

10981083
private String replace(final String source, final String original, final String replacement) {
@@ -1457,13 +1442,10 @@ private String printCell(Cell cell) {
14571442
}
14581443

14591444
private String addLinks(String startCell, String displayName, String rawfilename) {
1460-
String result = startCell;
1461-
result = result + "<a style=\"color:inherit\" title=\"Detailed Unit Test Results Table\" href=" + "\""
1462-
+ getHrefTestResultsTargetPath() + "/html/" + rawfilename + HTML_EXTENSION + "\">" + displayName + "</a>";
1463-
result = result
1445+
return startCell + "<a style=\"color:inherit\" title=\"Detailed Unit Test Results Table\" href=\""
1446+
+ getHrefTestResultsTargetPath() + "/html/" + rawfilename + HTML_EXTENSION + "\">" + displayName + "</a>"
14641447
+ "<a style=\"color:#555555\" title=\"XML Test Result (e.g. for importing into the Eclipse JUnit view)\" href=\""
1465-
+ getHrefTestResultsTargetPath() + "/xml/" + rawfilename + XML_EXTENSION + "\">&nbsp;(XML)</a>";
1466-
return result + "</td>";
1448+
+ getHrefTestResultsTargetPath() + "/xml/" + rawfilename + XML_EXTENSION + "\">&nbsp;(XML)</a></td>";
14671449
}
14681450

14691451
public boolean isRegenerate() {

0 commit comments

Comments
 (0)