Skip to content

Commit 17f5561

Browse files
author
jantje
committed
fix unit tests #1593
1 parent 56e9862 commit 17f5561

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

io.sloeber.core/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Require-Bundle: org.eclipse.cdt.managedbuilder.core,
2121
org.eclipse.ui.console,
2222
org.eclipse.debug.core,
2323
org.eclipse.core.variables,
24-
org.apache.commons.io,
24+
org.apache.commons.commons-io,
2525
org.apache.commons.compress
2626
Export-Package: cc.arduino.packages;x-internal:=true,
2727
cc.arduino.packages.discoverers;x-internal:=true,

io.sloeber.product/sloeber.target

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<unit id="org.eclipse.ecf.core.feature.group" version="0.0.0"/>
3131
<unit id="org.eclipse.wildwebdeveloper.feature.feature.group" version="0.0.0"/>
3232
</location>
33-
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" label="DirectFromMaven" missingManifest="error" type="Maven">
33+
<location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" label="DirectFromMaven" missingManifest="error" type="Maven">
3434
<dependencies>
3535
<dependency>
3636
<groupId>com.google.code.gson</groupId>
@@ -41,13 +41,13 @@
4141
<dependency>
4242
<groupId>org.apache.commons</groupId>
4343
<artifactId>commons-compress</artifactId>
44-
<version>1.23.0</version>
44+
<version>1.25.0</version>
4545
<type>jar</type>
4646
</dependency>
4747
<dependency>
4848
<groupId>commons-io</groupId>
4949
<artifactId>commons-io</artifactId>
50-
<version>2.13.0</version>
50+
<version>2.15.0</version>
5151
<type>jar</type>
5252
</dependency>
5353
</dependencies>

io.sloeber.tests/src/io/sloeber/core/Shared.java

+15-18
Original file line numberDiff line numberDiff line change
@@ -351,25 +351,22 @@ private static void extractFile(ZipInputStream zipIn, String filePath) throws IO
351351
* make the strings equal.
352352
*/
353353
public static String[] difference(String a, String b) {
354-
return diffHelper(a, b, new HashMap<>());
355-
}
356-
357-
@SuppressWarnings("boxing")
358-
private static String[] diffHelper(String a, String b, Map<Long, String[]> lookup) {
359-
return lookup.computeIfAbsent(((long) a.length()) << 32 | b.length(), k -> {
360-
if (a.isEmpty() || b.isEmpty()) {
361-
return new String[] { a, b };
362-
} else if (a.charAt(0) == b.charAt(0)) {
363-
return diffHelper(a.substring(1), b.substring(1), lookup);
354+
int startDiff = 1;
355+
while (a.substring(0, startDiff).equals(b.substring(0, startDiff))) {
356+
startDiff++;
357+
}
358+
int endDiff = startDiff + 20;
359+
if (startDiff > 10) {
360+
int nl = a.substring(0, startDiff).lastIndexOf('\n');
361+
if (nl != -1) {
362+
startDiff = nl;
364363
} else {
365-
String[] aa = diffHelper(a.substring(1), b, lookup);
366-
String[] bb = diffHelper(a, b.substring(1), lookup);
367-
if (aa[0].length() + aa[1].length() < bb[0].length() + bb[1].length()) {
368-
return new String[] { a.charAt(0) + aa[0], aa[1] };
369-
}
370-
return new String[] { bb[0], b.charAt(0) + bb[1] };
364+
startDiff = startDiff - 5;
371365
}
372-
});
366+
} else {
367+
startDiff = 0;
368+
}
369+
return new String[] { a.substring(startDiff, endDiff), b.substring(startDiff, endDiff) };
373370
}
374-
//end of copied from https://stackoverflow.com/questions/18344721/extract-the-difference-between-two-strings-in-java
371+
375372
}

io.sloeber.tests/src/io/sloeber/junit/AllJUnitTests.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
import org.junit.runners.Suite;
55
import org.junit.runners.Suite.SuiteClasses;
66

7+
/*
8+
* these junit tests need to be run as a junit plugin
9+
*
10+
*
11+
* TxtWorkAroundRegression.class is not included as it needs a special setup to run
12+
* The special setup is a arduinoplugin folder with "old" sloeber.txt files so the differences can be spotted
13+
*/
14+
715
@RunWith(Suite.class)
816
@SuiteClasses({ TestPlatformWorkAround.class, TestSerialPlotterFilter.class, TestTxtFile.class, TestWorkAround.class,
9-
TxtWorkAroundRegression.class, TestVersionCompare.class })
17+
TestVersionCompare.class })
1018
public class AllJUnitTests {
1119
//no need for code here
1220
}

0 commit comments

Comments
 (0)