MathewWi / umple

Automatically exported from code.google.com/p/umple
0 stars 0 forks source link

Creating a Model from a file in a subdir, then "linking" a model in same subdir fails to compile #684

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create two files, sub/Teacher2.ump (content: "class Teacher2 {}"), and 
sub/student2.ump (content: "class Student2 {}")
2. Create an Umple Model: 
  Umple File uFile = new UmpleFile("sub/Teacher2.ump");
  uFile.addLinkedFiles("sub/student2.ump");
  UmpleModel model = new UmpleModel(uFile);
3. Run the model
  model.run();

What is the expected output? What do you see instead?
Expected: Compile passes and the model has the specified classes are present
Actual: Fails to run stating:
  cruise.umple.compiler.exceptions.UmpleCompilerException: Error 1510 on line 1 of file "Teacher2.ump":
  File 'student2.ump' referred to in use statement was not found

    at cruise.umple.compiler.UmpleModel.run(UmpleModel.java:1132)
    at cruise.umple.compiler.UmpleModelTest.umpleFileWithLinkedFilesSubDir(UmpleModelTest.java:125)

This test script will show the error: 
https://gist.github.com/Nava2/1768f0cfa8520b825713

Original issue reported on code.google.com by kevin.br...@gmail.com on 3 Mar 2015 at 5:54

GoogleCodeExporter commented 9 years ago

Original comment by kevin.br...@gmail.com on 3 Mar 2015 at 5:54

GoogleCodeExporter commented 9 years ago
I was incorrect about one thing, it does not matter where the "base" file is. 
I've adjusted the test script. 

Using "Teacher2.ump" instead of "sub/Teacher2.ump" still fails. 

Original comment by kevin.br...@gmail.com on 3 Mar 2015 at 6:16

GoogleCodeExporter commented 9 years ago

Original comment by kevin.br...@gmail.com on 3 Mar 2015 at 6:16

GoogleCodeExporter commented 9 years ago
I'm confident it is because when you specify Linked Files, there is no path 
resolution happening. Thus, instead of checking if the file specified is in the 
same folder as the "base" file, it just arbitrarily adds the path. This results 
in the use statement looking for "sub" directories. 

I'm unsure how to proceed, if adjusting it to make it do path resolution is the 
correct path, or introducing a different API and holding the old one as is. 

Original comment by kevin.br...@gmail.com on 3 Mar 2015 at 6:21

GoogleCodeExporter commented 9 years ago
Tests in UmpleModelTest.java have been commented out pending this. 

Original comment by kevin.br...@gmail.com on 3 Mar 2015 at 6:44

GoogleCodeExporter commented 9 years ago
"use" relative paths are (or should) be from respect to the file itself, not 
the origin of the caller.  So you added "sub/Teacher2.ump", but "linking" it 
(which is like a use) would be relative to "sub", so it should be

uFile.addLinkedFiles("student2.ump");

This provides for deterministic relative paths.  Please re-test and if 
confirmed we can close this ticket as works as expected.

Original comment by aforw...@gmail.com on 3 Mar 2015 at 8:28

GoogleCodeExporter commented 9 years ago
You are correct Andrew, I've modified how the Ant task works to take this into 
account. The ant task now makes any files specified as Linked files be made 
relative to the src files' directory. 

The build has just kicked off on Travis to make sure my changes are correct. I 
did add tests to make sure that this is the case and is held. 
https://travis-ci.org/Nava2/Umple/builds/52981108

Original comment by kevin.br...@gmail.com on 4 Mar 2015 at 12:40

GoogleCodeExporter commented 9 years ago
Closing this as Fixed, it was kind of invalid, kind of not. The issue was 
actually with the Ant Tasks. 

Original comment by kevin.br...@gmail.com on 9 Mar 2015 at 4:37