Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2015-06-07 12:43:48 -0400
committerEd Willink2015-06-07 12:47:11 -0400
commite531c842972f8551287a04b685c2b99ec0aebfe7 (patch)
treec963ea602357129183c95855a955c6bef738e4d0
parentb21a01d796c926624a9b7f7948c9744a039add4c (diff)
downloadorg.eclipse.qvtd-e531c842972f8551287a04b685c2b99ec0aebfe7.tar.gz
org.eclipse.qvtd-e531c842972f8551287a04b685c2b99ec0aebfe7.tar.xz
org.eclipse.qvtd-e531c842972f8551287a04b685c2b99ec0aebfe7.zip
[469560] Add a debug launch test0.12.0RC4maintenance/R0_12
-rw-r--r--plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java4
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/QVTiDebuggerTests.java165
3 files changed, 166 insertions, 6 deletions
diff --git a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java
index 4e4394ac0..73d06be59 100644
--- a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java
+++ b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java
@@ -157,7 +157,9 @@ public class QVTiVMEvaluator implements IVMEvaluator
}
@Override
- public void saveModels() {}
+ public void saveModels() {
+ vmModelManager.saveModels();
+ }
@Override
public void setSuspendOnStartUp(boolean suspendOnStartup) {
diff --git a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/META-INF/MANIFEST.MF
index 8f3515ed3..3acaaeb73 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/META-INF/MANIFEST.MF
@@ -19,7 +19,8 @@ Require-Bundle: org.junit,
org.eclipse.qvtd.codegen;bundle-version="[0.12.0,0.13.0)",
org.eclipse.qvtd.xtext.qvtimperative;bundle-version="[0.12.0,0.13.0)";visibility:=reexport,
org.eclipse.qvtd.xtext.qvtbase.tests;bundle-version="[0.12.0,0.13.0)";visibility:=reexport,
- org.eclipse.qvtd.debug
+ org.eclipse.qvtd.debug,
+ org.eclipse.ocl.examples.debug.vm;bundle-version="[2.0.0,3.0.0)"
Export-Package: org.eclipse.qvtd.xtext.qvtimperative.tests,
classes,
classes.impl,
diff --git a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/QVTiDebuggerTests.java b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/QVTiDebuggerTests.java
index 749e77331..56cc814c9 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/QVTiDebuggerTests.java
+++ b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/QVTiDebuggerTests.java
@@ -10,32 +10,94 @@
*******************************************************************************/
package org.eclipse.qvtd.xtext.qvtimperative.tests;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IVariable;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.ocl.examples.debug.vm.core.VMVariable;
import org.eclipse.ocl.examples.xtext.tests.TestUIUtil;
import org.eclipse.ocl.examples.xtext.tests.TestUtil;
import org.eclipse.ocl.examples.xtext.tests.XtextTestCase;
+import org.eclipse.ocl.pivot.Variable;
+import org.eclipse.ocl.pivot.utilities.NameUtil;
+import org.eclipse.qvtd.debug.core.QVTiDebugTarget;
+import org.eclipse.qvtd.debug.evaluator.QVTiVMRootEvaluationEnvironment;
import org.eclipse.qvtd.debug.launching.QVTiLaunchConstants;
+import org.eclipse.qvtd.debug.vm.QVTiVMVirtualMachine;
+import org.eclipse.qvtd.pivot.qvtbase.Transformation;
+import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
+import org.eclipse.qvtd.pivot.qvtimperative.utilities.QVTimperativeUtil;
/**
* Tests that load a model and verify that there are no unresolved proxies as a result.
*/
public class QVTiDebuggerTests extends XtextTestCase
{
+ protected static final @NonNull String PC_NAME = "$pc";
+
+ private void checkPosition(@NonNull IThread vmThread, int lineNumber, int charStart, int charEnd) throws DebugException {
+ IStackFrame topStackFrame = vmThread.getTopStackFrame();
+ assertEquals("lineNumber", lineNumber, topStackFrame.getLineNumber());
+ assertEquals("charStart", charStart, topStackFrame.getCharStart());
+ assertEquals("charEnd", charEnd, topStackFrame.getCharEnd());
+ }
+
+ private void checkVariable(@NonNull IThread vmThread, @NonNull String name, @Nullable Object expectedValue) throws DebugException {
+ IStackFrame topStackFrame = vmThread.getTopStackFrame();
+ IVariable[] variables = topStackFrame.getVariables();
+ if (variables != null){
+ for (IVariable variable : variables) {
+ if (name.equals(variable.getName()) && (variable instanceof VMVariable)) {
+ Object valueObject = ((VMVariable)variable).getVmVar().valueObject;
+ assertEquals(expectedValue, valueObject);
+ return;
+ }
+ }
+ }
+ fail("Unknown variable '" + name + "'");
+ }
+
+ private void checkVariables(@NonNull IThread vmThread, String... names) throws DebugException {
+ List<String> expectedNames = new ArrayList<String>();
+ if (names != null){
+ for (String name : names) {
+ expectedNames.add(name);
+ }
+ }
+ Collections.sort(expectedNames);
+ IStackFrame topStackFrame = vmThread.getTopStackFrame();
+ IVariable[] variables = topStackFrame.getVariables();
+ List<String> actualNames = new ArrayList<String>();
+ if (variables != null){
+ for (IVariable variable : variables) {
+ actualNames.add(variable.getName());
+ }
+ }
+ Collections.sort(actualNames);
+ assertEquals(expectedNames, actualNames);
+ }
+
protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(@NonNull IProject iProject, @NonNull String launchName,
@NonNull URI transformationURI, @NonNull Map<String,String> inKeys, @NonNull Map<String,String> outKeys) throws CoreException {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
@@ -57,8 +119,7 @@ public class QVTiDebuggerTests extends XtextTestCase
TestUIUtil.closeIntro();
TestUIUtil.enableSwitchToDebugPerspectivePreference();
//
- IProject iProject = TestUIUtil.createIProject("QVTiDebuggerTests");
-// IFile launchFile = TestUIUtil.copyIFile(iProject.getFile("HSV2HLS.launch"), getProjectFileURI("HSV2HLS/HSV2HLS.launch"), null);
+ IProject iProject = TestUIUtil.createIProject("QVTiDebuggerRunTests");
IFile txFile = TestUIUtil.copyIFile(iProject.getFile("HSV2HLS.qvti"), getProjectFileURI("HSV2HLS/HSV2HLS.qvti"), "UTF-8");
TestUIUtil.copyIFile(iProject.getFile("HSVTree.ecore"), getProjectFileURI("HSV2HLS/HSVTree.ecore"), null);
TestUIUtil.copyIFile(iProject.getFile("HLSTree.ecore"), getProjectFileURI("HSV2HLS/HLSTree.ecore"), null);
@@ -82,8 +143,105 @@ public class QVTiDebuggerTests extends XtextTestCase
ILaunch launch = launchConfiguration.launch(ILaunchManager.RUN_MODE, null);
assert launch != null;
TestUIUtil.waitForLaunchToTerminate(launch);
+ for (int i = 0; i < 10; i++) {
+ outFile.refreshLocal(IResource.DEPTH_ZERO, null);
+ if (outFile.exists()) {
+ break;
+ }
+ TestUIUtil.wait(1000);
+ }
+ ResourceSet expectedResourceSet = new ResourceSetImpl();
+ Resource expectedResource = expectedResourceSet.getResource(getProjectFileURI("HSV2HLS/HLSNodeValidate.xmi"), true);
+ assert expectedResource != null;
+ ResourceSet actualResourceSet = new ResourceSetImpl();
+ Resource actualResource = actualResourceSet.getResource(outURI, true);
+ assert actualResource != null;
+ TestUtil.assertSameModel(expectedResource, actualResource);
+ }
+
+ public void testDebugger_Debug_HSV2HLS() throws Exception {
+ final @NonNull String inName = "hls";
+ final @NonNull String outName = "hsv";
+ final @NonNull String middleName = "middle";
+ //
+ TestUIUtil.closeIntro();
+ TestUIUtil.enableSwitchToDebugPerspectivePreference();
+ //
+ IProject iProject = TestUIUtil.createIProject("QVTiDebuggerDebugTests");
+ IFile txFile = TestUIUtil.copyIFile(iProject.getFile("HSV2HLS.qvti"), getProjectFileURI("HSV2HLS/HSV2HLS.qvti"), "UTF-8");
+ TestUIUtil.copyIFile(iProject.getFile("HSVTree.ecore"), getProjectFileURI("HSV2HLS/HSVTree.ecore"), null);
+ TestUIUtil.copyIFile(iProject.getFile("HLSTree.ecore"), getProjectFileURI("HSV2HLS/HLSTree.ecore"), null);
+ TestUIUtil.copyIFile(iProject.getFile("HSV2HLS.ecore"), getProjectFileURI("HSV2HLS/HSV2HLS.ecore"), null);
+ IFile inFile = TestUIUtil.copyIFile(iProject.getFile("HSVNode.xmi"), getProjectFileURI("HSV2HLS/HSVNode.xmi"), null);
+ IFile outFile = iProject.getFile("HLSNode.xmi");
+ IFile middleFile = iProject.getFile("HSV2HLSNode.xmi");
+ @SuppressWarnings("null")@NonNull URI txURI = URI.createPlatformResourceURI(txFile.getFullPath().toString(), true);
+ URI inURI = URI.createPlatformResourceURI(inFile.getFullPath().toString(), true);
+ URI outURI = URI.createPlatformResourceURI(outFile.getFullPath().toString(), true);
+ URI middleURI = URI.createPlatformResourceURI(middleFile.getFullPath().toString(), true);
+ Map<String,String> inMap = new HashMap<String,String>();
+ inMap.put(outName, inURI.toString());
+ Map<String,String> outMap = new HashMap<String,String>();
+ outMap.put(inName, outURI.toString());
+ outMap.put(middleName, middleURI.toString());
+
+ ILaunchConfigurationWorkingCopy launchConfiguration = createLaunchConfiguration(iProject, "HSV2HLS", txURI, inMap, outMap);
+ launchConfiguration.doSave();
+ TestUIUtil.flushEvents();
+ ILaunch launch = launchConfiguration.launch(ILaunchManager.DEBUG_MODE, null);
+ assert launch != null;
+ //
+/* Map<String, Object> attributes = launch.getLaunchConfiguration().getAttributes();
+ ExpressionInOCL asExpressionInOCL = (ExpressionInOCL) attributes.get(QVTiLaunchConstants.EXPRESSION_OBJECT);
+ OperationCallExp asOperationCallExp = (OperationCallExp) asExpressionInOCL.getOwnedBody();
+ PropertyCallExp asPropertyCallExpCallExp = (PropertyCallExp) asOperationCallExp.getOwnedSource();
+ VariableExp asVariableExp = (VariableExp) asPropertyCallExpCallExp.getOwnedSource();
+ NullLiteralExp asNullLiteralExp = (NullLiteralExp) asOperationCallExp.getOwnedArguments().get(0); */
+ //
+ QVTiDebugTarget debugTarget = (QVTiDebugTarget) launch.getDebugTarget();
+ QVTiVMVirtualMachine vm = (QVTiVMVirtualMachine) debugTarget.getVM();
+ QVTiVMRootEvaluationEnvironment vmRootEvaluationEnvironment = (QVTiVMRootEvaluationEnvironment) vm.getEvaluationEnv();
+ assert vmRootEvaluationEnvironment != null;
+ Transformation asTransformation = vmRootEvaluationEnvironment.getDebuggableElement();
+// QVTiVMEnvironmentFactory vmEnvironmentFactory = (QVTiVMEnvironmentFactory) vmEvaluationEnvironment.getVMEnvironmentFactory();
+// QVTiVMModelManager vmModelManager = (QVTiVMModelManager) vmRootEvaluationEnvironment.getModelManager();
+// vmModelManager.getTransformationInstance(transformation)
+ TypedModel inTypedModel = asTransformation.getModelParameter(inName);
+ TypedModel middleTypedModel = asTransformation.getModelParameter(middleName);
+ TypedModel outTypedModel = asTransformation.getModelParameter(outName);
+// Resource hls = vmModelManager.getModel(inTypedModel);
+// Resource hsv = vmModelManager.getModel(outTypedModel);
+// Resource middle = vmModelManager.getModel(middleTypedModel);
+ Variable asTransformationVariable = asTransformation.getOwnedContext();
+ Variable asInVariable = inTypedModel.getOwnedContext();
+ Variable asMiddleVariable = middleTypedModel.getOwnedContext();
+ Variable asOutVariable = outTypedModel.getOwnedContext();
+ assert (asTransformationVariable != null) && (asInVariable != null) && (asMiddleVariable != null) && (asOutVariable != null);
+
+ IThread vmThread = debugTarget.getThreads()[0];
+ assert vmThread != null;
+ TestUIUtil.waitForSuspended(vmThread);
+ //
+ checkPosition(vmThread, 8, 433, 447);
+ checkVariables(vmThread, PC_NAME, "this", outName, inName, middleName);
+ checkVariable(vmThread, PC_NAME, asTransformation);
+ checkVariable(vmThread, "this", vmRootEvaluationEnvironment.getValueOf(asTransformationVariable));
+ checkVariable(vmThread, outName, vmRootEvaluationEnvironment.getValueOf(asOutVariable));
+ checkVariable(vmThread, inName, vmRootEvaluationEnvironment.getValueOf(asInVariable));
+ checkVariable(vmThread, middleName, vmRootEvaluationEnvironment.getValueOf(asMiddleVariable));
+ //
+ vmThread.stepInto();
+ TestUIUtil.waitForSuspended(vmThread);
+ //
+ checkPosition(vmThread, 21, 1053, 1061);
+ checkVariables(vmThread, PC_NAME);
+ checkVariable(vmThread, PC_NAME, NameUtil.getNameable(asTransformation.getRule(), QVTimperativeUtil.ROOT_MAPPING_NAME));
+ //
+ vmThread.stepReturn();
+ TestUIUtil.waitForTerminated(vmThread);
+ assertEquals(0, vm.getExitCode());
+ //
TestUIUtil.flushEvents();
-// outFile.refreshLocal(IResource.DEPTH_ZERO, null);
ResourceSet expectedResourceSet = new ResourceSetImpl();
Resource expectedResource = expectedResourceSet.getResource(getProjectFileURI("HSV2HLS/HLSNodeValidate.xmi"), true);
assert expectedResource != null;
@@ -91,6 +249,5 @@ public class QVTiDebuggerTests extends XtextTestCase
Resource actualResource = actualResourceSet.getResource(outURI, true);
assert actualResource != null;
TestUtil.assertSameModel(expectedResource, actualResource);
-// ocl.dispose();
}
}

Back to the top