revert

parent 15b63a14
......@@ -35,7 +35,7 @@ import java.util.List;
*/
public class AutomaticStreamTestGenerator extends AbstractSymtab {
public TaggingResolver generateTests(String fullComponentInstanceName, String basePath, String targetPath, String testNamePostFix, int amountTickValues) throws Exception {
public void generateTests(String fullComponentInstanceName, String basePath, String targetPath, String testNamePostFix, int amountTickValues) throws Exception {
TaggingResolver symtab = createSymTabAndTaggingResolver(basePath);
EMAComponentInstanceSymbol componentSymbol = null;
if (fullComponentInstanceName.length() > 0) {
......@@ -46,8 +46,7 @@ public class AutomaticStreamTestGenerator extends AbstractSymtab {
generatorCPP.setGenerationTargetPath(targetPath);
generatorCPP.useArmadilloBackend();
generatorCPP.setModelsDirPath(Paths.get(basePath));
generatorCPP.setExecutionLoggingActive(true);
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
return symtab;
}
}
......@@ -20,19 +20,9 @@
*/
package de.monticore.lang.monticar.generator.testing;
import de.monticore.ast.ASTNode;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.SourcePosition;
import de.se_rwth.commons.logging.Log;
import java.io.*;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @author Sascha Schneiders
......@@ -48,72 +38,6 @@ public class StreamTestModifier {
writeLines(filePathStreamTest, streamTestLines);
}
public static String buildStackTrace(String resultsPath, TaggingResolver taggingResolver) throws IOException {
String res = "";
String timeStampsPath = resultsPath + "/TimeStamps.txt";
File timeStampsFile = new File(timeStampsPath);
if(!timeStampsFile.exists()){
Log.error("Can not find " + timeStampsPath);
return "";
}
List<String> lines = Files.readAllLines(timeStampsFile.toPath());
for(String resFileName : lines){
File curResFile = new File(resultsPath + "/" + resFileName + ".res");
if(curResFile.exists()){
String compInstName = getInstanceNameFromResFile(curResFile.getName());
EMAComponentInstanceSymbol symb = taggingResolver.<EMAComponentInstanceSymbol>resolve(compInstName, EMAComponentInstanceSymbol.KIND).orElse(null);
if(symb == null){
Log.warn("Can not find EMAComponentInstanceSymbol " + compInstName);
}else{
res += "Breakpoint reached\n";
EMAComponentInstanceSymbol curSym = symb;
while(curSym != null) {
res += "\tat ";
res += curSym.getFullName() + "(";
res += curSym
.getComponentType()
.getReferencedSymbol()
.getAstNode()
.map(ASTNode::get_SourcePositionStart)
.map(SourcePosition::getFileName)
.map(Optional::get)
.map(File::new)
.map(File::getName)
.orElse("unknown");
res += ":1)\n";
curSym = curSym.getParent().orElse(null);
}
}
res += "[INFO][]" + getVariableJsonDict(curResFile) + "\n";
}else{
Log.warn("Can not open " + curResFile.getName());
}
}
writeLines(resultsPath + "/stacktrace.log", Arrays.asList(res.split("\\n")));
return res;
}
private static String getInstanceNameFromResFile(String curResFile) {
return curResFile.replaceAll("^execution\\d*","").replaceAll("\\.res$","");
}
private static String getVariableJsonDict(File curResFile) throws IOException {
String curRes = "{";
List<String> tmp = Files.readAllLines(curResFile.toPath());
List<String> vars = new ArrayList<>();
for(String t : tmp){
String[] parts = t.split(" : ");
vars.add("\"" + parts[0] + "\" : \"" + parts[1] + "\"");
}
curRes += String.join(", ", vars);
curRes += "}";
return curRes;
}
public static List<String> filterOutput(List<String> content) {
List<String> filteredContent = new ArrayList<>();
List<PortNameValues> portNameValuesList = new ArrayList<>();
......
......@@ -249,14 +249,13 @@ public class AutomaticStreamTestGenerationTest extends AbstractSymtabTest {
@Test
public void testLoggingExample2() throws Exception {
AutomaticStreamTestGenerator generator = new AutomaticStreamTestGenerator();
TaggingResolver symtab = generator.generateTests("",
generator.generateTests("",
"src/test/resources/emastudio/autopilot", OSHelper.getDirPrefix() + "/target/generated-sources-cpp/streamtest/autopilot/", "1", 10);
testGenCPPFilesAndExecWithExecLogging("./target/generated-sources-cpp/streamtest", "/autopilot",
"./src/test/resources/emastudio/autopilot", "./target/generated-sources-cpp/streamtest/autopilot",
"de.rwth.armin.modeling.autopilot.motion.calculateEngineAndBrakes",
"de.rwth.armin.modeling.autopilot.motion.CalculateEngineAndBrakesTest1");
}
@Ignore //Does not work in maven for some reason
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment