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

Normalize line separators for .txt files (fix Windows tests) #3488

Merged
merged 2 commits into from
Jan 17, 2022

Conversation

KvanTTT
Copy link
Member

@KvanTTT KvanTTT commented Jan 11, 2022

No description provided.

@KvanTTT
Copy link
Member Author

KvanTTT commented Jan 11, 2022

I still don't understand how to force \n line separators for Windows instead of \r\n. Git doesn't accept the change of separators. All tests expect \n line separator.

@ericvergnaud
Copy link
Contributor

Have you tried: git config --global core.autocrlf false
See https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings

@KvanTTT
Copy link
Member Author

KvanTTT commented Jan 12, 2022

Yes, I've tried with no effect. Ok, I'll restore line separators processing and replace line separators tests with handwritten tests.

@parrt
Copy link
Member

parrt commented Jan 13, 2022

Oh sorry. didn't see this yet, @KvanTTT (Just emailed you).

@KvanTTT
Copy link
Member Author

KvanTTT commented Jan 13, 2022

Yes, I'm working on it.

@KvanTTT KvanTTT force-pushed the line-separator-fixes branch from 1e94a77 to bfb7efc Compare January 14, 2022 20:27
@KvanTTT KvanTTT marked this pull request as ready for review January 14, 2022 21:34
@KvanTTT
Copy link
Member Author

KvanTTT commented Jan 15, 2022

@parrt the fix is ready.

import java.util.List;

public class ExtraTests {
public static RuntimeTestDescriptor[] getRuntimeTestDescriptors(String targetName) {
Copy link
Member Author

Choose a reason for hiding this comment

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

These tests are useful. We can write here test for generated and very large grammars. For instance, LargeLexer.txt can be moved here.

Copy link
Member

Choose a reason for hiding this comment

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

Why not include LargeLexer etc... in main section?

Copy link
Member

Choose a reason for hiding this comment

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

Can you remind me what the purpose is for a new file ExtraTests.java ?

Copy link
Member

Choose a reason for hiding this comment

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

Is it only way to distinguish \r\n from \n tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not include LargeLexer etc... in main section?

Because it contains a lot of duplicated lines. It can be replaced by a short and clear test with several lines (also, it's possible to vary the number of tokens and other parameters).

Is it only way to distinguish \r\n from \n tests?

For now yes. But I'm working on #1863 and other related bugs that also require big tests that ideally should be generated.

Copy link
Member

@parrt parrt Jan 17, 2022

Choose a reason for hiding this comment

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

I'll try to think about this today. One first thought. We don't need the regex anymore if we use \n. split works great and is much easier to understand. Also means less change to existing code in a PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll remove regex. Definitely, now it does not make sense since we have other tests for line endings checking.

Copy link
Member Author

@KvanTTT KvanTTT Jan 17, 2022

Choose a reason for hiding this comment

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

Done. Please don't squash my commits since they are logically different.

Also, in the future, we can use use fixup! commits for easier changes review. Before the final PR merge, all !fixup are being merged to original commits for clear history. I mean !fixup Change something is being merged to Change something.

Copy link
Member

Choose a reason for hiding this comment

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

hi. the fixup thing might be hard for me to remember and complicate my life ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok. I just always use interactive rebase in IDEA and never have troubles :)

return result;
}

static RuntimeTestDescriptor getLargeLexerDescriptor(String targetName) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I've moved LargeLexer in the current PR for the demo.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Yeah, I'm still thinking we are making a big departure from the point of descriptor files to solve this \r\n thing. Seems we're off the road to shove in a test case for a tiny fraction of the number of tests

Copy link
Member Author

@KvanTTT KvanTTT Jan 16, 2022

Choose a reason for hiding this comment

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

I have yet another generated test getAtnStatesSizeMoreThan65535Descriptor in another PR. It's too excess to use yet another big file with uniform data. Output data is also being generated.

Copy link
Member

Choose a reason for hiding this comment

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

I see. yes, starting to make sense to me for generated examples.

@KvanTTT KvanTTT force-pushed the line-separator-fixes branch from 9021548 to 905001b Compare January 17, 2022 19:29
@parrt
Copy link
Member

parrt commented Jan 17, 2022

Ok, looking good now in my mind except that we've so far tried to group tests now by area like lexing, parsing. Instead of adding new TestExtra, shouldn't we add the new tests to TestLexer or whatever?

@parrt parrt added this to the 4.10 milestone Jan 17, 2022
@KvanTTT
Copy link
Member Author

KvanTTT commented Jan 17, 2022

Ok, maybe it makes sense. I just didn't want to mix descriptor and handwritten tests but probably it does not matter.

@parrt
Copy link
Member

parrt commented Jan 17, 2022

Ok, maybe it makes sense. I just didn't want to mix descriptor and handwritten tests but probably it does not matter.

yeah, probably better to mix gen vs files to keep test topics/areas the same. This way we can also avoid adding new TestX.java file

@parrt
Copy link
Member

parrt commented Jan 17, 2022

Seems github is hosed. This times out in actions: Download action repository 'stCarolas/setup-maven@v4' (SHA:1d56b37995622db66cce1214d81014b09807fb5a) Ah. it's moving now.

@KvanTTT KvanTTT force-pushed the line-separator-fixes branch from 905001b to 40ebc46 Compare January 17, 2022 20:32
@KvanTTT
Copy link
Member Author

KvanTTT commented Jan 17, 2022

yeah, probably better to mix gen vs files to keep test topics/areas the same. This way we can also avoid adding new TestX.java file

Indeed, much fewer changes.

Seems github is hosed. This times out in actions: Download action repository 'stCarolas/setup-maven@v4' (SHA:1d56b37995622db66cce1214d81014b09807fb5a)

That's probably a problem with self-hosted CI again. I see the following:

Error: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.

@parrt
Copy link
Member

parrt commented Jan 17, 2022

@ericvergnaud does the antlr data center look ok from your side? Any network issues? thanks!

@@ -367,6 +366,13 @@ public static ErrorQueue antlrOnString(String workdir,
System.err.println("Can't read descriptor file "+fname);
}
}

Copy link
Member

Choose a reason for hiding this comment

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

this makes me kinda nervous but better than altering all target test files I guess.

@@ -0,0 +1,68 @@
package org.antlr.v4.test.runtime;

public class ExtraTests {
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to be fussy but "Extra" isn't very specific. Maybe "GeneratedTests" or even "GeneratedLexerDescriptors"?

Copy link
Member

Choose a reason for hiding this comment

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

I'll merge then think/tweak of name

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I haven't found a better name. Generated is also not very correct since it contains line separator tests. Maybe handwritten or something like this.

@parrt parrt merged commit 6034525 into antlr:master Jan 17, 2022
@parrt
Copy link
Member

parrt commented Jan 17, 2022

Thanks for the hard work, @KvanTTT !

@KvanTTT KvanTTT deleted the line-separator-fixes branch January 17, 2022 22:00
@ericvergnaud
Copy link
Contributor

@ericvergnaud does the antlr data center look ok from your side? Any network issues? thanks!

No apparent issue here, some builds are successful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants