mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
Slide switch added
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<property name="jar.dir" value="${build.dir}/jar" />
|
||||
<property name="report.dir" value="${build.dir}/junitreport" />
|
||||
<property name="main.class" value="org.diylc.DIYLCStarter" />
|
||||
<property name="diylc.version" value="4.22.2" />
|
||||
<property name="diylc.version" value="4.23.0" />
|
||||
|
||||
<property name="osx.jre8.path" value="jre\osx\jre8u321\Contents\Home\" />
|
||||
|
||||
@@ -139,6 +139,9 @@
|
||||
<arg value="/Fdiylc-${diylc.version}-win"/>
|
||||
<arg value="install.iss"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="universal_installer" depends="jar">
|
||||
<izpack input="${basedir}/izpack.xml"
|
||||
output="${build.dir}/diylc-${diylc.version}-setup.jar"
|
||||
installerType="standard"
|
||||
@@ -162,6 +165,7 @@
|
||||
<zipfileset dir="icons" includes="*.png" prefix="icons" />
|
||||
<zipfileset dir="flatpak" includes="com.diy_fever.DIYLayoutCreator.desktop" />
|
||||
<zipfileset dir="flatpak" includes="com.diy_fever.DIYLayoutCreator.metainfo.xml" />
|
||||
<zipfileset dir="jre/win/jre1.8.0_211" prefix="jre" />
|
||||
</zip>
|
||||
<checksum file="${build.dir}/diylc-${diylc.version}.zip" algorithm="SHA-256"/>
|
||||
</target>
|
||||
|
||||
@@ -3,16 +3,13 @@ package org.diylc;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -23,12 +20,9 @@ import java.util.stream.Stream;
|
||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||
import org.diylc.appframework.miscutils.InMemoryConfigurationManager;
|
||||
import org.diylc.appframework.update.VersionNumber;
|
||||
import org.diylc.common.INetlistAnalyzer;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.netlist.Netlist;
|
||||
import org.diylc.netlist.Summary;
|
||||
import org.diylc.netlist.TreeException;
|
||||
import org.diylc.presenter.Presenter;
|
||||
import org.diylc.swing.plugins.file.ProjectDrawingProvider;
|
||||
import org.diylc.swingframework.export.DrawingExporter;
|
||||
@@ -232,62 +226,105 @@ public class RegressionTestRunner {
|
||||
return res.failed("Images do not match!");
|
||||
}
|
||||
|
||||
List<INetlistAnalyzer> summarizers = presenter.getNetlistAnalyzers();
|
||||
if (summarizers != null) {
|
||||
List<Netlist> netlists = presenter.extractNetlists(true);
|
||||
List<Netlist> netlists = presenter.extractNetlists(true);
|
||||
File netlistOutputDir = new File(
|
||||
file.getParentFile().getParentFile().getAbsolutePath() + File.separator + "netlist");
|
||||
File netlistOutputFile = new File(netlistOutputDir.getAbsolutePath() + File.separator
|
||||
+ file.getName().replace(".diy", ".txt"));
|
||||
File netlistInputFile = new File(inputDir.getAbsolutePath() + File.separator + "netlist"
|
||||
+ File.separator + (file.getName().replace(".diy", ".txt")));
|
||||
|
||||
for (INetlistAnalyzer summarizer : summarizers) {
|
||||
File summaryOutputDir =
|
||||
new File(outputDir.getAbsolutePath() + File.separator + summarizer.getShortName());
|
||||
File summaryOutputFile = new File(summaryOutputDir.getAbsolutePath() + File.separator
|
||||
+ file.getName().replace(".diy", ".txt"));
|
||||
summaryOutputDir.mkdirs();
|
||||
if (summaryOutputFile.exists()) {
|
||||
summaryOutputFile.delete();
|
||||
netlistOutputDir.mkdirs();
|
||||
try {
|
||||
if (netlistOutputFile.exists()) {
|
||||
netlistOutputFile.delete();
|
||||
}
|
||||
try {
|
||||
try (BufferedWriter writer = new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(netlistOutputFile, true), "UTF-8"))) {
|
||||
for (Netlist netlist : netlists) {
|
||||
writer.write(netlist.toString());
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
File summaryInputDir = new File(file.getParentFile().getParentFile().getAbsolutePath()
|
||||
+ File.separator + summarizer.getShortName());
|
||||
File summaryInputFile = new File(summaryInputDir.getAbsolutePath() + File.separator
|
||||
+ file.getName().replace(".diy", ".txt"));
|
||||
|
||||
if (!summaryInputFile.exists()) {
|
||||
return res.failed("Summary input file not found for: " + summarizer.getShortName());
|
||||
}
|
||||
|
||||
try {
|
||||
List<String> outputLines = new ArrayList<String>();
|
||||
try {
|
||||
writeSummariesToFile(netlists, summarizer, summaryOutputFile);
|
||||
outputLines = Files.readAllLines(Paths.get(summaryOutputFile.getAbsolutePath()));
|
||||
} catch (Exception e) {
|
||||
try (BufferedWriter writer = new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(summaryOutputFile, true), "UTF-8"))) {
|
||||
String line = e.getClass().getCanonicalName() + ": " + e.getMessage();
|
||||
writer.write(line);
|
||||
outputLines.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> inputLines =
|
||||
Files.readAllLines(Paths.get(summaryInputFile.getAbsolutePath()));
|
||||
|
||||
if (inputLines.size() != outputLines.size()) {
|
||||
return res.failed(
|
||||
"Summary input and output files do not match for: " + summarizer.getShortName());
|
||||
}
|
||||
for (int i = 0; i < inputLines.size(); i++) {
|
||||
if (!inputLines.get(i).equals(outputLines.get(i))) {
|
||||
return res.failed(
|
||||
"Summary input and output files do not match for: " + summarizer.getShortName());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return res.failed(e.getMessage());
|
||||
} catch (Exception e) {
|
||||
try (BufferedWriter writer = new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(netlistOutputFile, true), "UTF-8"))) {
|
||||
writer.write(e.getClass().getCanonicalName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
List<String> inputLines = Files.readAllLines(Paths.get(netlistInputFile.getAbsolutePath()));
|
||||
List<String> outputLines = Files.readAllLines(Paths.get(netlistOutputFile.getAbsolutePath()));
|
||||
|
||||
if (inputLines.size() != outputLines.size()) {
|
||||
return res.failed("Netlists do not match");
|
||||
}
|
||||
for (int i = 0; i < inputLines.size(); i++) {
|
||||
if (!inputLines.get(i).equals(outputLines.get(i))) {
|
||||
return res.failed("Netlists do not match");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return res.failed(e.getMessage());
|
||||
}
|
||||
|
||||
// List<INetlistAnalyzer> summarizers = presenter.getNetlistAnalyzers();
|
||||
// if (summarizers != null) {
|
||||
// List<Netlist> netlists = presenter.extractNetlists(true);
|
||||
//
|
||||
// for (INetlistAnalyzer summarizer : summarizers) {
|
||||
// File summaryOutputDir =
|
||||
// new File(outputDir.getAbsolutePath() + File.separator + summarizer.getShortName());
|
||||
// File summaryOutputFile = new File(summaryOutputDir.getAbsolutePath() + File.separator
|
||||
// + file.getName().replace(".diy", ".txt"));
|
||||
// summaryOutputDir.mkdirs();
|
||||
// if (summaryOutputFile.exists()) {
|
||||
// summaryOutputFile.delete();
|
||||
// }
|
||||
//
|
||||
// File summaryInputDir = new File(file.getParentFile().getParentFile().getAbsolutePath()
|
||||
// + File.separator + summarizer.getShortName());
|
||||
// File summaryInputFile = new File(summaryInputDir.getAbsolutePath() + File.separator
|
||||
// + file.getName().replace(".diy", ".txt"));
|
||||
//
|
||||
// if (!summaryInputFile.exists()) {
|
||||
// return res.failed("Summary input file not found for: " + summarizer.getShortName());
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// List<String> outputLines = new ArrayList<String>();
|
||||
// try {
|
||||
// writeSummariesToFile(netlists, summarizer, summaryOutputFile);
|
||||
// outputLines = Files.readAllLines(Paths.get(summaryOutputFile.getAbsolutePath()));
|
||||
// } catch (Exception e) {
|
||||
// try (BufferedWriter writer = new BufferedWriter(
|
||||
// new OutputStreamWriter(new FileOutputStream(summaryOutputFile, true), "UTF-8"))) {
|
||||
// String line = e.getClass().getCanonicalName() + ": " + e.getMessage();
|
||||
// writer.write(line);
|
||||
// outputLines.add(line);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<String> inputLines =
|
||||
// Files.readAllLines(Paths.get(summaryInputFile.getAbsolutePath()));
|
||||
//
|
||||
// if (inputLines.size() != outputLines.size()) {
|
||||
// return res.failed(
|
||||
// "Summary input and output files do not match for: " + summarizer.getShortName());
|
||||
// }
|
||||
// for (int i = 0; i < inputLines.size(); i++) {
|
||||
// if (!inputLines.get(i).equals(outputLines.get(i))) {
|
||||
// return res.failed(
|
||||
// "Summary input and output files do not match for: " + summarizer.getShortName());
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// return res.failed(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
String message = null;
|
||||
if (!view.getMessages().isEmpty()) {
|
||||
message = view.getMessages().entrySet().stream().flatMap(x -> x.getValue().stream())
|
||||
@@ -310,51 +347,75 @@ public class RegressionTestRunner {
|
||||
// always export image to ensure that rendering is done and continuity areas are populated
|
||||
DrawingExporter.getInstance().exportPNG(drawingProvider, pngFile);
|
||||
|
||||
List<INetlistAnalyzer> summarizers = plugInPort.getNetlistAnalyzers();
|
||||
if (summarizers != null) {
|
||||
List<Netlist> netlists = plugInPort.extractNetlists(true);
|
||||
List<Netlist> netlists = plugInPort.extractNetlists(true);
|
||||
File netlistDir = new File(
|
||||
file.getParentFile().getParentFile().getAbsolutePath() + File.separator + "netlist");
|
||||
File netlistFile = new File(
|
||||
netlistDir.getAbsolutePath() + File.separator + file.getName().replace(".diy", ".txt"));
|
||||
|
||||
for (INetlistAnalyzer summarizer : summarizers) {
|
||||
File summaryDir = new File(file.getParentFile().getParentFile().getAbsolutePath()
|
||||
+ File.separator + summarizer.getShortName());
|
||||
File summaryFile = new File(summaryDir.getAbsolutePath() + File.separator
|
||||
+ file.getName().replace(".diy", ".txt"));
|
||||
summaryDir.mkdirs();
|
||||
if (!summaryFile.exists()) {
|
||||
try {
|
||||
writeSummariesToFile(netlists, summarizer, summaryFile);
|
||||
|
||||
} catch (Exception e) {
|
||||
try (BufferedWriter writer = new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(summaryFile, true), "UTF-8"))) {
|
||||
writer.write(e.getClass().getCanonicalName() + ": " + e.getMessage());
|
||||
}
|
||||
netlistDir.mkdirs();
|
||||
if (!netlistFile.exists()) {
|
||||
try {
|
||||
try (BufferedWriter writer = new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(netlistFile, true), "UTF-8"))) {
|
||||
for (Netlist netlist : netlists) {
|
||||
writer.write(netlist.toString());
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
try (BufferedWriter writer = new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(netlistFile, true), "UTF-8"))) {
|
||||
writer.write(e.getClass().getCanonicalName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// List<INetlistAnalyzer> summarizers = plugInPort.getNetlistAnalyzers();
|
||||
// if (summarizers != null) {
|
||||
//
|
||||
//
|
||||
// for (INetlistAnalyzer summarizer : summarizers) {
|
||||
// summaryDir = new File(file.getParentFile().getParentFile().getAbsolutePath()
|
||||
// + File.separator + summarizer.getShortName());
|
||||
// summaryFile = new File(summaryDir.getAbsolutePath() + File.separator
|
||||
// + file.getName().replace(".diy", ".txt"));
|
||||
// summaryDir.mkdirs();
|
||||
// if (!summaryFile.exists()) {
|
||||
// try {
|
||||
// writeSummariesToFile(netlists, summarizer, summaryFile);
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// try (BufferedWriter writer = new BufferedWriter(
|
||||
// new OutputStreamWriter(new FileOutputStream(summaryFile, true), "UTF-8"))) {
|
||||
// writer.write(e.getClass().getCanonicalName() + ": " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} catch (Exception e) {
|
||||
return res.failed(e.getMessage());
|
||||
}
|
||||
return res.succedded();
|
||||
}
|
||||
|
||||
private static void writeSummariesToFile(List<Netlist> netlists, INetlistAnalyzer summarizer,
|
||||
File summaryFile)
|
||||
throws TreeException, IOException, UnsupportedEncodingException, FileNotFoundException {
|
||||
List<Summary> summaries = summarizer.summarize(netlists, null);
|
||||
|
||||
try (BufferedWriter writer = new BufferedWriter(
|
||||
new OutputStreamWriter(new FileOutputStream(summaryFile, true), "UTF-8"))) {
|
||||
for (Summary summary : summaries) {
|
||||
writer.write("<b>Switch configuration: ");
|
||||
writer.write(summary.getNetlist().getSwitchSetup().toString());
|
||||
writer.write("</b><br><br>");
|
||||
writer.write(summary.getSummary());
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
// private static void writeSummariesToFile(List<Netlist> netlists, INetlistAnalyzer summarizer,
|
||||
// File summaryFile)
|
||||
// throws TreeException, IOException, UnsupportedEncodingException, FileNotFoundException {
|
||||
// List<Summary> summaries = summarizer.summarize(netlists, null);
|
||||
//
|
||||
// try (BufferedWriter writer = new BufferedWriter(
|
||||
// new OutputStreamWriter(new FileOutputStream(summaryFile, true), "UTF-8"))) {
|
||||
// for (Summary summary : summaries) {
|
||||
// writer.write("<b>Switch configuration: ");
|
||||
// writer.write(summary.getNetlist().getSwitchSetup().toString());
|
||||
// writer.write("</b><br><br>");
|
||||
// writer.write(summary.getSummary());
|
||||
// writer.newLine();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
static class RegressionTestResult {
|
||||
boolean ok;
|
||||
|
||||
Reference in New Issue
Block a user