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

Port test.sh to platform independent D. #551

Merged
merged 4 commits into from
May 29, 2022

Conversation

veelo
Copy link
Contributor

@veelo veelo commented May 24, 2022

This executes also way faster by not spawning GNU diff (at least on Windows).

@veelo
Copy link
Contributor Author

veelo commented May 24, 2022

This script simply ignores differences in line ending, unless --end_of_line is one of the arguments to dfmt.

tests/test.d Outdated Show resolved Hide resolved
@veelo veelo marked this pull request as draft May 24, 2022 08:08
@veelo
Copy link
Contributor Author

veelo commented May 24, 2022

I am keeping this in draft for the moment because on Windows dfmt seems to generate LF line endings by default, which is unexpected. If that is indeed the case, this script should probably not ignore line endings like is does now.

@veelo veelo force-pushed the d_test_script branch 4 times, most recently from 14659b7 to 8e33d12 Compare May 24, 2022 15:49
@veelo veelo marked this pull request as ready for review May 24, 2022 15:50
@veelo
Copy link
Contributor Author

veelo commented May 24, 2022

I had it backwards yesterday night: the script should be correct in it's current state for the current dfmt behaviour. Once #552 is addressed, the script can be simplified to always compare line endings.

I intentionally did not touch test.sh, as devs on Posix might want to test both versions for a while to make sure I didn't miss anything.

This should be ready for review now.

This executes also way faster by not spawning GNU diff.
@veelo veelo requested a review from maxhaton May 26, 2022 14:13
@WebFreak001 WebFreak001 self-requested a review May 26, 2022 15:01
@maxhaton
Copy link
Contributor

Seems OK to me.

Copy link
Member

@WebFreak001 WebFreak001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might make sense to force an --end_of_line parameter to all dfmt calls, so all files are always tested with the platform native EOL string (if not changed to anything else)

tests/test.d Outdated Show resolved Hide resolved
tests/test.d Outdated Show resolved Hide resolved
@veelo
Copy link
Contributor Author

veelo commented May 27, 2022

I think it might make sense to force an --end_of_line parameter to all dfmt calls, so all files are always tested with the platform native EOL string (if not changed to anything else)

That will make tests fail for anyone that has configured Git to check out files with line endings that differ from what is native to the platform (apparently, such people exist).

I think the suggestion made in #552 is better, because then tests are run in the same manner on every platform:

The most versatile solution would probably be to inspect the first n lines of input and see what the dominating line endings are there, and use that as default for the entire output.

EDIT: well, not "in the same manner", that will depend on Git settings, but I mean the script will not special-case the platform if dfmt keeps the same line endings between input and output.

Co-authored-by: Jan Jurzitza <gh@webfreak.org>
@veelo
Copy link
Contributor Author

veelo commented May 29, 2022

Can we get this merged please? I have a PR for #552 ready that assumes this.

@maxhaton maxhaton merged commit ed5fc2f into dlang-community:master May 29, 2022
@veelo
Copy link
Contributor Author

veelo commented May 29, 2022

Thanks, that was quick!

@veelo veelo deleted the d_test_script branch May 29, 2022 23:17
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