eclipse / epsilon

Epsilon is a family of Java-based scripting languages for automating common model-based software engineering tasks, such as code generation, model-to-model transformation and model validation, that work out of the box with EMF (including Xtext and Sirius), UML (including Cameo/MagicDraw), Simulink, XML and other types of models.
https://eclipse.org/epsilon
Eclipse Public License 2.0
66 stars 10 forks source link

Flexmi models with EUnit results in an "Premature end of file" #67

Closed micfort closed 8 months ago

micfort commented 9 months ago

There seems to be a problem in loading models when loading flexmi models in a EUnit task. When I do that I get a Test test1 {} failed with status ERROR: Premature end of file. error. When I convert the models to xmi, the problem dissapears. I have made a small example where it happens. I'm using epsilon 2.4.0.

build.xml:

<project default="main" xmlns:ivy="antlib:org.apache.ivy.ant">
    <target name="main">
        <!-- test that the model is actually working -->
        <epsilon.emf.loadModel name="ModelA"
                            modelFile="TestModel.flexmi" 
                            metamodelFile="metamodel.emf" 
                            read="true" store="false" />
        <epsilon.eol>
            <model ref="ModelA"/>
            ModelA!Element.all.first().Message.println();
        </epsilon.eol>
        <epsilon.disposeModel model="ModelA"/>

        <!-- does not work with flexmi files -->
        <epsilon.eunit src="test.eunit">
            <modelTasks>
                <epsilon.emf.loadModel name="ModelA"
                    modelFile="TestModel.flexmi" 
                    metamodelFile="metamodel.emf" 
                    read="true" store="false" />
                <epsilon.emf.loadModel name="ModelB"
                    modelFile="TestModel.flexmi" 
                    metamodelFile="metamodel.emf" 
                    read="true" store="false" />
            </modelTasks>
        </epsilon.eunit>
    </target>
</project>

Metamodel.emf:

@namespace(uri="NS", prefix="")
package NS;

class Element {
    attr String Message;
}

TestModel.flexmi:

<?nsuri NS?>
<Element Message="Some Message"/>

test.eunit:

@test
operation test1() {
  assertEqualModels("ModelA", "ModelB");
}
agarciadom commented 9 months ago

I have not been able to reproduce this while running from the latest version of Epsilon. Can you confirm if you were running this build.xml from inside Eclipse, and could you try again with the latest interim version of Epsilon?

micfort commented 9 months ago

I have just downloaded Epsilon (from https://eclipse.dev/epsilon/download/) on my personal pc, made a copy of all the files, registered the EPackages and ran ANT. Where ANT is run in the same JRE as the workspace.

Then I get the following output


Buildfile: /home/michiel/eclipse/epsilon-2-4/workspace/test/build.xml

main:
 [epsilon.eol] Some Message
Test test1 {} failed with status ERROR: Premature end of file.
Test root {} failed with status ERROR: Premature end of file.
Global result: ERROR

BUILD FAILED
/home/michiel/eclipse/epsilon-2-4/workspace/test/build.xml:15: At least one test case had a failure or an error: Premature end of file.
    at (/home/michiel/eclipse/epsilon-2-4/workspace/test/test.eunit@3:2-3:40)
    at (/home/michiel/eclipse/epsilon-2-4/workspace/test/test.eunit@3:2-3:40)
    at (/home/michiel/eclipse/epsilon-2-4/workspace/test/test.eunit@2:18-4:1)
    at (/home/michiel/eclipse/epsilon-2-4/workspace/test/test.eunit@0:0-4:1)

Total time: 150 milliseconds
agarciadom commented 8 months ago

Sorry for the late reply. Which version did you download? Was it the interim version, or the stable one? I could not reproduce your issue with the latest interim version.

micfort commented 8 months ago

The latest stable one, but for people that come across this issue in the future it is as follows:

kolovos commented 8 months ago

I have reproduced this issue with 2.4.0, but it appears to have been fixed in 2.5.0.