Skip to content
Snippets Groups Projects
Commit a17dda9e authored by Dominik Hansen's avatar Dominik Hansen
Browse files

Tests are running in a single JVM.

Former-commit-id: 7962a277c354d1911205b8445b380a240d401ccd
parent dd2cd0ec
No related branches found
No related tags found
No related merge requests found
......@@ -40,17 +40,17 @@ compileJava {
}
test {
//exclude('de/b2tla/tlc/integration/**')
exclude('de/b2tla/tlc/integration/**')
}
task integrationtest(type: Test){
forkEvery = 1
doFirst{
println("Running integration tests")
}
scanForTestClasses = true
include('de/b2tla/tlc/integration/**')
}
jar { from sourceSets.main.allJava }
......@@ -61,7 +61,7 @@ manifest.mainAttributes("Main-Class" : 'de.b2tla.B2TLA')
manifest.mainAttributes("Class-Path": './tla/ tla2tools.jar')
task copy(dependsOn: jar) << {
task copy(dependsOn: build) << {
copy {
from('build/libs/')
into('build/b2tla')
......
......@@ -48,10 +48,9 @@ public class B2TLA {
}
StopWatch.stop("Translation");
if (Globals.runTLC) {
ArrayList<String> output = TLCRunner.runTLCInANewJVM(
ArrayList<String> output = TLCRunner.runTLC(
b2tla.machineName, b2tla.path);
b2tla.evalOutput(output, false);
}
}
......@@ -67,7 +66,7 @@ public class B2TLA {
}
if (Globals.runTLC) {
ArrayList<String> output = TLCRunner.runTLCInANewJVM(
ArrayList<String> output = TLCRunner.runTLC(
b2tla.machineName, b2tla.path);
ERROR error = TLCOutput.findError(output);
System.out.println(error);
......@@ -76,6 +75,7 @@ public class B2TLA {
return null;
}
private void evalOutput(ArrayList<String> output, boolean createTraceFile) {
TLCOutput tlcOutput = new TLCOutput(machineName,
output.toArray(new String[output.size()]));
......
......@@ -13,6 +13,4 @@ public class Globals {
public static boolean setupConstants = false;
public static boolean deleteOnExit = false;
public static TLCOutput tlcOutput = null;
}
......@@ -44,7 +44,7 @@ public class TLCRunner {
}
String[] args = list.toArray(new String[list.size()]);
ProcessHelper helper = new ProcessHelper();
System.out.println("Starting TLC...");
System.out.println("Starting JVM...");
Process p = helper.startNewJavaProcess("", TLCRunner.class.getName(),
args);
......@@ -61,7 +61,7 @@ public class TLCRunner {
return stdOut.getLog();
}
public static void runTLCOld(String machineName, String path) {
public static ArrayList<String> runTLC(String machineName, String path) {
ArrayList<String> list = new ArrayList<String>();
if (!Globals.deadlockCheck) {
list.add("-deadlock");
......@@ -75,7 +75,7 @@ public class TLCRunner {
// ByteArrayOutputStream os = new ByteArrayOutputStream();
// PrintStream ps = new PrintStream(os);
BTLCPrintStream btlcStream = new BTLCPrintStream();
PrintStream old = System.out;
PrintStream systemOut = System.out;
System.setOut(btlcStream);
ToolIO.setMode(ToolIO.SYSTEM);
......@@ -86,20 +86,34 @@ public class TLCRunner {
// call the actual processing method
tlc.process();
}
System.setOut(old);
System.setOut(systemOut);
ArrayList<String> messages = btlcStream.getArrayList();
String[] messages = btlcStream.getArray();
System.out.println(Arrays.asList(messages));
TLCOutput tlcOutput = new TLCOutput(machineName, messages);
tlcOutput.parseTLCOutput();
Globals.tlcOutput = tlcOutput;
closeThreads();
return messages;
//TLCOutput tlcOutput = new TLCOutput(machineName, messages);
//tlcOutput.parseTLCOutput();
// TLCOutputEvaluator evaluator = new TLCOutputEvaluator(machineName,
// messages);
System.out.println("ERROR: " + tlcOutput.getError());
StringBuilder trace = tlcOutput.getErrorTrace();
if (tlcOutput.hasTrace()) {
createfile(path, machineName + ".tla.trace", trace.toString());
//System.out.println("ERROR: " + tlcOutput.getError());
//StringBuilder trace = tlcOutput.getErrorTrace();
// if (tlcOutput.hasTrace()) {
// createfile(path, machineName + ".tla.trace", trace.toString());
// }
}
private static void closeThreads() {
Set<Thread> threadSet = new HashSet<Thread>(Thread.getAllStackTraces().keySet());
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
for (int i = 0; i < threadArray.length; i++) {
Thread t = threadArray[i];
//System.out.println(t.getId()+ " "+t.getThreadGroup());
if(t.getName().equals("RMI Reaper")){
t.interrupt();
}
}
//System.exit(0);
}
public static void createfile(String dir, String fileName, String text) {
......
......@@ -24,30 +24,24 @@ public class BTLCPrintStream extends PrintStream {
return array.toArray(new String[array.size()]);
}
/**
* @param args
*/
public static void main(String[] args) {
BTLCPrintStream my = new BTLCPrintStream();
System.setOut(my);
System.out.print("hallo");
public ArrayList<String> getArrayList(){
return array;
}
@Override
public void println(String str){
synchronized (BTLCPrintStream.class){
if(!Globals.tool){
// console.println(str);
console.println("> " + str);
}
array.add(str);
}
}
@Override
public void print(String str){
synchronized (BTLCPrintStream.class){
//console.println(str);
console.println(str);
array.add(str);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment