Skip to content
Snippets Groups Projects
Commit bd378107 authored by dgelessus's avatar dgelessus
Browse files

Move getMachines methods into TestUtil

parent d9cc292e
No related branches found
No related tags found
No related merge requests found
...@@ -9,38 +9,11 @@ import de.tlc4b.tlc.TLCResults.TLCResult; ...@@ -9,38 +9,11 @@ import de.tlc4b.tlc.TLCResults.TLCResult;
import de.tlc4b.util.PolySuite.Configuration; import de.tlc4b.util.PolySuite.Configuration;
public abstract class AbstractParseMachineTest { public abstract class AbstractParseMachineTest {
private static final String MCH_SUFFIX = ".mch";
protected static File[] getMachines(String path) {
return new File(path).listFiles((dir, name) -> name.endsWith(MCH_SUFFIX));
}
protected static List<File> getMachinesRecursively(String path) {
File root = new File(path);
File[] list = root.listFiles();
List<File> files = new ArrayList<>();
if (list == null)
return files;
for (File f : list) {
if (f.isDirectory()) {
files.addAll(getMachinesRecursively(f.getAbsolutePath()));
} else {
String name = f.getName();
if (name.endsWith(MCH_SUFFIX)) {
files.add(f);
}
}
}
return files;
}
protected static Configuration getConfiguration2(List<String> list) { protected static Configuration getConfiguration2(List<String> list) {
List<File> allMachines = new ArrayList<>(); List<File> allMachines = new ArrayList<>();
for (String path : list) { for (String path : list) {
allMachines.addAll(getMachinesRecursively(path)); allMachines.addAll(TestUtil.getMachinesRecursively(path));
} }
return new Configuration() { return new Configuration() {
...@@ -66,7 +39,7 @@ public abstract class AbstractParseMachineTest { ...@@ -66,7 +39,7 @@ public abstract class AbstractParseMachineTest {
List<File> allMachines = new ArrayList<>(); List<File> allMachines = new ArrayList<>();
for (String path : list) { for (String path : list) {
allMachines.addAll(Arrays.asList(getMachines(path))); allMachines.addAll(Arrays.asList(TestUtil.getMachines(path)));
} }
return new Configuration() { return new Configuration() {
......
package de.tlc4b.util; package de.tlc4b.util;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
...@@ -23,6 +24,34 @@ import static de.tlc4b.TLC4BOption.NOTRACE; ...@@ -23,6 +24,34 @@ import static de.tlc4b.TLC4BOption.NOTRACE;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class TestUtil { public class TestUtil {
private static final String MCH_SUFFIX = ".mch";
public static File[] getMachines(String path) {
return new File(path).listFiles((dir, name) -> name.endsWith(MCH_SUFFIX));
}
public static List<File> getMachinesRecursively(String path) {
File root = new File(path);
File[] list = root.listFiles();
List<File> files = new ArrayList<>();
if (list == null) {
return files;
}
for (File f : list) {
if (f.isDirectory()) {
files.addAll(getMachinesRecursively(f.getAbsolutePath()));
} else {
String name = f.getName();
if (name.endsWith(MCH_SUFFIX)) {
files.add(f);
}
}
}
return files;
}
public static void compare(final String expectedModule, final String machineString) throws BCompoundException, TLA2BException { public static void compare(final String expectedModule, final String machineString) throws BCompoundException, TLA2BException {
TLC4BGlobals.setForceTLCToEvalConstants(false); TLC4BGlobals.setForceTLCToEvalConstants(false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment