Selaa lähdekoodia

Extract Method to retreive sgen model (#1637)

* Extract Method to retreive sgen model

* Get TestLogger into GeneratorExecutor

* Add option to specify compiler

* Revert "Get TestLogger into GeneratorExecutor"

This reverts commit 32d9a94be1b9d87c4ba26adb67ae445664cf3689.
Rene Beckmann 8 vuotta sitten
vanhempi
commit
79f04ed3d4

+ 1 - 5
test-plugins/org.yakindu.sct.generator.c.test/src/org/yakindu/sct/generator/c/gtest/GMockHelper.java

@@ -5,6 +5,7 @@ import java.util.List;
 public class GMockHelper extends GTestHelper {
 	public GMockHelper(Object owner) {
 		super(owner);
+		this.compiler = Compiler.GPLUSPLUS;
 	}
 	
 	@Override
@@ -14,9 +15,4 @@ public class GMockHelper extends GTestHelper {
 		command.add("-lgmock_main");
 		return command;
 	}
-	
-	@Override
-	protected String getCompilerCommand() {
-		return "g++";
-	}
 }

+ 31 - 5
test-plugins/org.yakindu.sct.generator.c.test/src/org/yakindu/sct/generator/c/gtest/GTestHelper.java

@@ -49,11 +49,32 @@ import org.yakindu.sct.model.sgraph.Statechart;
  * 
  */
 public class GTestHelper {
+	
+	/**
+	 * @author rbeckmann
+	 *
+	 */
+	public enum Compiler {
+		GCC ("gcc"), GPLUSPLUS ("g++");
+		
+		protected String command;
+		
+		Compiler(String command) {
+			this.command = command;
+		}
+		
+		public String getCommand() {
+			return this.command;
+		}
+	}
 
 	private final Object owner;
-
+	protected Compiler compiler;
+	
+	
 	public GTestHelper(Object owner) {
 		this.owner = owner;
+		this.compiler = Compiler.GCC;
 	}
 
 	public void compile() {
@@ -74,15 +95,20 @@ public class GTestHelper {
 		String sgenFileName = getSgenFileName(getTestProgram());
 		copyFileFromBundleToFolder(getTestBundle(), sgenFileName, targetPath);
 
-		IPath path = new Path(sgenFileName);
-		Resource sgenResource = loadResource(getWorkspaceFileFor(path));
-		GeneratorModel model = (GeneratorModel) sgenResource.getContents().get(0);
+		GeneratorModel model = getGeneratorModel(sgenFileName);
 		model.getEntries().get(0).setElementRef(getStatechart());
 
 		performFullBuild();
 
 		getGeneratorExecutorLookup().execute(model);
 	}
+
+	protected GeneratorModel getGeneratorModel(String sgenFileName) {
+		IPath path = new Path(sgenFileName);
+		Resource sgenResource = loadResource(getWorkspaceFileFor(path));
+		GeneratorModel model = (GeneratorModel) sgenResource.getContents().get(0);
+		return model;
+	}
 	
 	protected List<String> getFilesToCopy() {
 		return new ArrayList<String>(Arrays.asList(owner.getClass().getAnnotation(GTest.class).additionalFilesToCopy()));
@@ -180,7 +206,7 @@ public class GTestHelper {
 	 * @return
 	 */
 	protected String getCompilerCommand() {
-		return "gcc";
+		return this.compiler.getCommand();
 	}
 
 	/**