diff --git a/io.sloeber.core/META-INF/MANIFEST.MF b/io.sloeber.core/META-INF/MANIFEST.MF index a9204be91..24de054ff 100644 --- a/io.sloeber.core/META-INF/MANIFEST.MF +++ b/io.sloeber.core/META-INF/MANIFEST.MF @@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.cdt.managedbuilder.core, org.eclipse.ui.console, org.eclipse.debug.core, org.eclipse.core.variables, - org.apache.commons.io, + org.apache.commons.commons-io, org.apache.commons.compress Export-Package: cc.arduino.packages;x-internal:=true, cc.arduino.packages.discoverers;x-internal:=true, diff --git a/io.sloeber.product/sloeber.target b/io.sloeber.product/sloeber.target index eae14e186..d82236d8b 100644 --- a/io.sloeber.product/sloeber.target +++ b/io.sloeber.product/sloeber.target @@ -30,7 +30,7 @@ - + com.google.code.gson @@ -41,13 +41,13 @@ org.apache.commons commons-compress - 1.23.0 + 1.25.0 jar commons-io commons-io - 2.13.0 + 2.15.0 jar diff --git a/io.sloeber.tests/src/io/sloeber/core/Shared.java b/io.sloeber.tests/src/io/sloeber/core/Shared.java index b54adb8d4..f03276b00 100644 --- a/io.sloeber.tests/src/io/sloeber/core/Shared.java +++ b/io.sloeber.tests/src/io/sloeber/core/Shared.java @@ -351,25 +351,22 @@ private static void extractFile(ZipInputStream zipIn, String filePath) throws IO * make the strings equal. */ public static String[] difference(String a, String b) { - return diffHelper(a, b, new HashMap<>()); - } - - @SuppressWarnings("boxing") - private static String[] diffHelper(String a, String b, Map lookup) { - return lookup.computeIfAbsent(((long) a.length()) << 32 | b.length(), k -> { - if (a.isEmpty() || b.isEmpty()) { - return new String[] { a, b }; - } else if (a.charAt(0) == b.charAt(0)) { - return diffHelper(a.substring(1), b.substring(1), lookup); + int startDiff = 1; + while (a.substring(0, startDiff).equals(b.substring(0, startDiff))) { + startDiff++; + } + int endDiff = startDiff + 20; + if (startDiff > 10) { + int nl = a.substring(0, startDiff).lastIndexOf('\n'); + if (nl != -1) { + startDiff = nl; } else { - String[] aa = diffHelper(a.substring(1), b, lookup); - String[] bb = diffHelper(a, b.substring(1), lookup); - if (aa[0].length() + aa[1].length() < bb[0].length() + bb[1].length()) { - return new String[] { a.charAt(0) + aa[0], aa[1] }; - } - return new String[] { bb[0], b.charAt(0) + bb[1] }; + startDiff = startDiff - 5; } - }); + } else { + startDiff = 0; + } + return new String[] { a.substring(startDiff, endDiff), b.substring(startDiff, endDiff) }; } - //end of copied from https://stackoverflow.com/questions/18344721/extract-the-difference-between-two-strings-in-java + } diff --git a/io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java b/io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java index 8f7f09196..375e1c73f 100644 --- a/io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java +++ b/io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java @@ -4,9 +4,17 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +/* + * these junit tests need to be run as a junit plugin + * + * + * TxtWorkAroundRegression.class is not included as it needs a special setup to run + * The special setup is a arduinoplugin folder with "old" sloeber.txt files so the differences can be spotted + */ + @RunWith(Suite.class) @SuiteClasses({ TestPlatformWorkAround.class, TestSerialPlotterFilter.class, TestTxtFile.class, TestWorkAround.class, - TxtWorkAroundRegression.class, TestVersionCompare.class }) + TestVersionCompare.class }) public class AllJUnitTests { //no need for code here }