WriteLog anfügen

This commit is contained in:
JanUlrich 2015-10-15 16:28:10 +02:00
parent a541b353cd
commit 88b1c3e57c

View File

@ -3,17 +3,21 @@ package bytecode;
import java.io.File;
import java.io.IOException;
import com.google.common.io.Files;
import junit.framework.TestCase;
import de.dhbwstuttgart.core.MyCompiler;
import de.dhbwstuttgart.core.MyCompilerAPI;
import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.LoggerConfiguration;
import de.dhbwstuttgart.logger.Section;
import de.dhbwstuttgart.logger.Timewatch;
import de.dhbwstuttgart.parser.JavaParser.yyException;
import de.dhbwstuttgart.typeinference.ByteCodeResult;
import de.dhbwstuttgart.typeinference.Menge;
public class SingleClassTester {
public static void compileToBytecode(String inputFile, String outputFile){
LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out);
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
@ -25,7 +29,19 @@ public class SingleClassTester {
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}finally{
writeLog(outputFile+".log");
}
}
private static void writeLog(String toFile){
String log = Logger.getWholeLog()+"\n";
log+=Timewatch.getTimewatch().dumpTimeData();
try {
Files.write(log.getBytes(),new File(toFile));
} catch (IOException e) {
e.printStackTrace();
TestCase.fail();
}
}
}