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
53 stars 11 forks source link

Some tests fail when run from Windows #96

Closed leomylonas closed 4 weeks ago

leomylonas commented 1 month ago

I found a couple problems when running the test suite from my Windows computer.

  1. The new EpsilonDebugAdapter tests contain a code path which calls URI#getPath(), however this produces an invalid file path on Windows when the URI is a file: URI. Using Paths#get(URI) produces a valid Windows file path. Additionally, there were some hard coded Unix line endings in some expected values.

  2. Some of the EUnit tests compare an expected file on the filesystem with a generated file. The expected file has Unix line endings, but a generated file on Windows will produce a file with Windows line endings. The current comparison method will (rather correctly) indicate these files are not equal. I've added 2 new EUnit assertion operations to compare files ignoring line endings, allowing users to opt in to this slightly relaxed behavior should they desire it.

I wasn't able to find where the source code for the documentation resides, so I wasn't able to update it. Please let me know where I can find it and I'd be happy to update it. EDIT: I found it! I've added a PR for the above changes https://github.com/eclipse/epsilon-website/pull/34

EDIT: There were mixed line endings in FileUtil.java, so I standardised them to Unix. Sorry for the big whitespace diff! 😅

leomylonas commented 1 month ago

Ready for review @agarciadom @kolovos

leomylonas commented 1 month ago

Side note, I'm aware that number 2 in my description may not be a problem for people on Windows who's git config is setup with autocrlf=true, since the expected file will contain Windows line endings when cloned. I don't like this setting and always have it turned off.

agarciadom commented 1 month ago

Thanks for the catch! I usually develop on Linux and Dimitris usually develops on Mac, so we missed this. I think it may also be time to finally add a Github workflow that runs the tests across Linux, Mac, and Windows 😅 .

I've just finished setting up a Windows dev environment, and I'll review this in the upcoming days.

agarciadom commented 1 month ago

I've just pushed an additional commit, after noticing that the recursive call to the new sameContents method was not passing along the ignoreLineEndings flag - fixed that. I also used try-with-resources blocks to ensure open file handles were released appropriately after the comparison. I'll continue looking at the PR later on.

agarciadom commented 4 weeks ago

I've gone through the other commits, and it all looks good to me. I tried running the tests locally from Windows, and they all pass. I'll merge this now: thank you for your contribution!