Commit 7288f669 authored by Christoph Richter's avatar Christoph Richter
Browse files

Made StreamTest executable, generated by CMake, name unique

parent 38ac7473
Pipeline #67181 passed with stage
in 2 minutes and 55 seconds
......@@ -8,7 +8,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-generator</artifactId>
<version>0.0.23-SNAPSHOT</version>
<version>0.0.24-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......
......@@ -167,7 +167,7 @@ public class GeneratorCPP implements Generator {
Scope symtab) throws IOException {
List<FileContent> fileContents = generateStrings(taggingResolver, componentSymbol, symtab);
fileContents.addAll(generateTypes(TypeConverter.getTypeSymbols()));
fileContents.addAll(handleTestAndCheckDir(symtab));
fileContents.addAll(handleTestAndCheckDir(symtab, componentSymbol));
if (isGenerateAutopilotAdapter()) {
fileContents.addAll(getAutopilotAdapterFiles(componentSymbol));
}
......@@ -207,11 +207,11 @@ public class GeneratorCPP implements Generator {
return files;
}
public List<FileContent> handleTestAndCheckDir(Scope symtab) {
public List<FileContent> handleTestAndCheckDir(Scope symtab, ExpandedComponentInstanceSymbol componentSymbol) {
List<FileContent> fileContents = new ArrayList<>();
if (isGenerateTests() || isCheckModelDir()) {
TestsGeneratorCPP g = new TestsGeneratorCPP(this);
List<FileContent> fileConts = g.generateStreamTests(symtab);
List<FileContent> fileConts = g.generateStreamTests(symtab, componentSymbol);
fileContents.addAll(fileConts);
}
return fileContents;
......
......@@ -167,7 +167,7 @@ public final class GeneratorCppCli {
if (componentSymbol != null) {
g.generateFiles(componentSymbol, symTab);
} else {
g.saveFilesToDisk(g.handleTestAndCheckDir(symTab));
g.saveFilesToDisk(g.handleTestAndCheckDir(symTab, componentSymbol));
}
} catch (IOException e) {
Log.error("error during generation", e);
......
......@@ -43,7 +43,7 @@ public final class TestsGeneratorCPP {
this.generator = Log.errorIfNull(generator);
}
public List<FileContent> generateStreamTests(Scope symTab) {
public List<FileContent> generateStreamTests(Scope symTab, ExpandedComponentInstanceSymbol componentSymbol) {
bluePrints = new ArrayList<>(generator.getBluePrints());
findStreams(symTab);
findComponents(symTab);
......@@ -52,7 +52,7 @@ public final class TestsGeneratorCPP {
Log.warn("no blue prints were generated");
//return Collections.emptyList();
}
return generateFiles();
return generateFiles(componentSymbol);
}
private void findStreams(Scope symTab) {
......@@ -65,7 +65,7 @@ public final class TestsGeneratorCPP {
availableComponents = componentScanner.scan();
}
private List<FileContent> generateFiles() {
private List<FileContent> generateFiles(ExpandedComponentInstanceSymbol componentSymbol) {
testedComponents = new HashSet<>();
files = new ArrayList<>();
viewModelForMain = new TestsMainEntryViewModel();
......@@ -93,15 +93,21 @@ public final class TestsGeneratorCPP {
}
// add to cmake lists
if (generator.isGenerateCMakeEnabled())
addTestExecutionToCMakeConfig();
addTestExecutionToCMakeConfig(componentSymbol);
return files;
}
private void addTestExecutionToCMakeConfig() {
private void addTestExecutionToCMakeConfig(ExpandedComponentInstanceSymbol componentSymbol) {
// executable name
String name;
if (componentSymbol != null)
name = componentSymbol.getFullName().replace('.', '_').replace('[', '_').replace(']', '_') + "_StreamTests";
else
name = "StreamTests";
CMakeConfig cmake = generator.getCMakeConfig();
cmake.addCMakeCommandEnd("include_directories(test)");
cmake.addCMakeCommandEnd("add_executable(StreamTests test/tests_main.cpp)");
cmake.addCMakeCommandEnd("target_compile_definitions(StreamTests PRIVATE CATCH_CONFIG_MAIN=1 ARMA_DONT_USE_WRAPPER)");
cmake.addCMakeCommandEnd("target_compile_definitions(" + name + " PRIVATE CATCH_CONFIG_MAIN=1 ARMA_DONT_USE_WRAPPER)");
}
private String getExistingComponentNames() {
......
......@@ -65,7 +65,7 @@ public class GenerateCMakeTest extends AbstractSymtabTest {
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerateCMake(true);
generatorCPP.setGenerationTargetPath("./target/generated-sources-cpp/cmake/test/BasicPortsMath");
generatorCPP.setModelsDirPath(Paths.get("src/test/resources"));
generatorCPP.setModelsDirPath(Paths.get("src/test/resources/"));
generatorCPP.setGenerateTests(true);
generatorCPP.setCheckModelDir(true);
List<File> files = generatorCPP.generateFiles(componentSymbol, symtab);
......@@ -82,7 +82,7 @@ public class GenerateCMakeTest extends AbstractSymtabTest {
findFiles.add(f);
else if (f.getName().endsWith(".hpp") || f.getName().endsWith(".cpp"))
testFiles.add(f);
else if (f.getName().endsWith(".txt")) {
else if (f.toPath().getParent().endsWith("reporting")) {
//don't care about reporting files
}
else
......
......@@ -26,4 +26,4 @@ export(TARGETS test_basicPortsMath FILE test_basicPortsMath.cmake)
# additional commands end
include_directories(test)
add_executable(StreamTests test/tests_main.cpp)
target_compile_definitions(StreamTests PRIVATE CATCH_CONFIG_MAIN=1 ARMA_DONT_USE_WRAPPER)
target_compile_definitions(test_basicPortsMath_StreamTests PRIVATE CATCH_CONFIG_MAIN=1 ARMA_DONT_USE_WRAPPER)
Supports Markdown
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