Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

review test: fix line separators in test #2111

Merged
merged 1 commit into from
Jun 27, 2018

Conversation

surli
Copy link
Collaborator

@surli surli commented Jun 26, 2018

This PR is a first one in order to fix test on windows: when we set line.separator we need to reset it to its old value afterwards.

This alone won't fix all tests on windows: we also need to remove all \n usage and to use systematically System.getProperty("line.separator");. This will be done in another PR.

@surli surli mentioned this pull request Jun 26, 2018
@surli surli changed the title test: fix line separators in test review test: fix line separators in test Jun 26, 2018
@pvojtechovsky
Copy link
Collaborator

This PR is a first one in order to fix test on windows: when we set line.separator we need to reset it to its old value afterwards.

why to reset it back? We can assume that all spoon tests will use linux separator \n

I think it is not main contract of Spoon tests to "play" with OS specific separators. So I suggest to keep spoon tests as simple as possible and to always expect linux EOL.

We can make one test which checks that system property "line.separator" is taken into account by DJPP and that's all. This test should try all possible EOLs of all possible OSes.

This alone won't fix all tests on windows: we also need to remove all \n usage and to use systematically System.getProperty("line.separator");

I guess it makes spoon tests more complicated and brings no advantage - in worst case it will still pass on some OS and fail on other OS... so we get OS specific tests. I guess it is not good.

WDYT?

@surli
Copy link
Collaborator Author

surli commented Jun 26, 2018

We can assume that all spoon tests will use linux separator \n

That's not the case: I saw that we're using System.getProperty("line.separator") instead of \n in some tests.

I have the feeling that keeping \n in tests is a bad idea: we are using the line separator property in DJPP, which means that in all tests that are using DJPP we should reset the property to \n.

It seems more natural to me to force the usage of the get property everwhere in the tests: then 1. we'll test properly the expected behaviour and 2. we don't risk to miss any call to properly set the line separator property.

I agree with you on the fact that we should keep test as simple as possible but for me it seems easier to understand a test with a line separator get by the property, than a test with a before annotation somewhere which reset this property.

@pvojtechovsky
Copy link
Collaborator

ok, I do not persist on my opinion.

Just do not modify tests related to content of comments. Note that comment values are always separated by \n and it is independent on OS. I think it is a nice feature. When DJPP prints such comments back to sources then it can use OS specific EOL, but the code which works with comments is much simpler if it is not OS specific.

@monperrus monperrus merged commit 8583aee into INRIA:master Jun 27, 2018
@surli surli deleted the fix-line-separators-in-test branch June 27, 2018 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants