diff --git a/build.gradle b/build.gradle index 84d381c8f1b6c9dc322ffea4831efbe5a4ba0afb..294c5f31558fe17ee8d2a691d0535f87e28c6d66 100644 --- a/build.gradle +++ b/build.gradle @@ -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') diff --git a/src/main/java/de/b2tla/B2TLA.java b/src/main/java/de/b2tla/B2TLA.java index 135816829e9b7768bed8a9bd59c0fcb61a847abb..5b271daad9b70363d59292d75c8a89593c7671ac 100644 --- a/src/main/java/de/b2tla/B2TLA.java +++ b/src/main/java/de/b2tla/B2TLA.java @@ -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()])); diff --git a/src/main/java/de/b2tla/Globals.java b/src/main/java/de/b2tla/Globals.java index 813f9e8f16c06b66fb76f49cc89a9cce936d3ac8..228e7ad60e26f3a7e43b849ce034c5de5b4a0050 100644 --- a/src/main/java/de/b2tla/Globals.java +++ b/src/main/java/de/b2tla/Globals.java @@ -13,6 +13,4 @@ public class Globals { public static boolean setupConstants = false; public static boolean deleteOnExit = false; - - public static TLCOutput tlcOutput = null; } diff --git a/src/main/java/de/b2tla/TLCRunner.java b/src/main/java/de/b2tla/TLCRunner.java index fe8024ac66b8de41b05e78e998628b069e63c65c..64b14f3cd8a7437273373aea5c3e09ba977fd965 100644 --- a/src/main/java/de/b2tla/TLCRunner.java +++ b/src/main/java/de/b2tla/TLCRunner.java @@ -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,22 +86,36 @@ public class TLCRunner { // call the actual processing method tlc.process(); } - System.setOut(old); - - String[] messages = btlcStream.getArray(); - System.out.println(Arrays.asList(messages)); - TLCOutput tlcOutput = new TLCOutput(machineName, messages); - tlcOutput.parseTLCOutput(); - Globals.tlcOutput = tlcOutput; + System.setOut(systemOut); + + ArrayList<String> messages = btlcStream.getArrayList(); + + 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) { File d = new File(dir); d.mkdirs(); diff --git a/src/main/java/de/b2tla/util/BTLCPrintStream.java b/src/main/java/de/b2tla/util/BTLCPrintStream.java index 7b18894f7ff4de5947a670de9816b955c52ebf1d..f75ca32309a33cd3584f4c94a97695b8d0c151c8 100644 --- a/src/main/java/de/b2tla/util/BTLCPrintStream.java +++ b/src/main/java/de/b2tla/util/BTLCPrintStream.java @@ -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); } }