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

[Go] Fix for issue 3557 -- get "go test" working again #3558

Merged
merged 1 commit into from
Feb 26, 2022

Conversation

kaby76
Copy link
Contributor

@kaby76 kaby76 commented Feb 23, 2022

What does this PR fix?

Discussion

This is a fix for the Go runtime so that "go test" works. The problem is that some of the runtime tests are within the runtime itself, and I don't think they are tested in GitHub Actions.

The change is essentially a couple of test files in the runtime. One of the files didn't explicitly state the "LexerA.g4" grammar, so I inserted a comment so people don't need to guess WTF it is.

Why is this PR important?

It's blocking testing for another PR I want to make.

@kaby76
Copy link
Contributor Author

kaby76 commented Feb 23, 2022

Prereq for #3548

Comment on lines +14 to +21
/* Assume the following grammar for this test.

lexer grammar LexerA;
A : 'a';
B : 'b';
C : 'c';

*/
Copy link
Member

Choose a reason for hiding this comment

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

Where did you take it from? Probably it should be extracted to a separate file.

Copy link
Contributor Author

@kaby76 kaby76 Feb 24, 2022

Choose a reason for hiding this comment

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

Of course it should be in a file. But, so should the grammar in the comment here.

But, even if we decide to leave it here, and pull out the grammars into files, and generate the lexers for testing, the generated code will not build. That's because we have the lovely global variable problem. And, rather than deal with the problem in an intelligent manner, the output from the tool is "cleverly" hand-edited.

Even if we fix #3452, API tests should not even go here. How can one test the visibility of the API from within the package? It's all just wrong. The tests should not be here. It needs to go into the runtime-testsuite directory.

Oh yes, the grammar I got was just an educated guess after looking at the output that was there before. But, I didn't actually analyze the automaton produced representing in the tables. So, who knows if this is right. The "experts" are so much smarter than I. I only have a ~1/2 century of programming that I have done, but it's nothing.

Copy link
Member

Choose a reason for hiding this comment

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

So, who knows if this is right. The "experts" are so much smarter than I. I only have a ~1/2 century of programming that I have done, but it's nothing.

Everyone can mistake despite the big experience as well as suggest a good solution. And it's okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's normal to make mistakes. We are all human. It's wrong to not take ownership. This has been here for a long time, enough time to reflect and try to fix.

I think it best to add the code as is. #3452 / #3264 needs to be addressed post 4.10. I have a fix for this, but it needs to be integrated with a fix with #3446, which I also have.

@parrt parrt added this to the 4.10 milestone Feb 26, 2022
@parrt
Copy link
Member

parrt commented Feb 26, 2022

thanks!

@parrt parrt merged commit 3bb9ffe into antlr:dev Feb 26, 2022
@parrt
Copy link
Member

parrt commented Feb 26, 2022

@kaby76 let me know if you need anything else :)

@jimidle
Copy link
Collaborator

jimidle commented Mar 4, 2023

Guys - I don't think we should go down this path for Go testing. I think it needs me to dedicate some serious time to write Go runtime tests in Go idiomatic form. I am going to do some serious rummaging around in the go runtime in the next few weeks, and when I have got the performance where I think it should be, then I will look at stuff like this.

Talking of performance, when I get some changes in to the dev branch, perhaps you will have time to run the comparison benchmark you have @kaby76 ? That seems some serious effort you put in there. I would like to get Go performance to be top of the tree. I know what is wrong, but some of the go stuff will require quite a bit of, shall we say, "correcting" to get rid of useless memory allocations and the like.

go test./... does work from the /v4 code, but there are valuable tests in there right now.

I suggest that we close this. BTW - I am just going through all PRs and issue that pertain to Go at the moment so I can clean them up/rework them/ask for them to be closed. Start with a clean slate so to speak.

@kaby76
Copy link
Contributor Author

kaby76 commented Mar 4, 2023

@jimidle I'll be looking at performance for Go soon. My plan is to: clean up and extend the test driver generator used in testing grammars-v4; add "individual" parsing back into selected targets and grammars, because "grouped" parsing (aka "warm-up") doesn't help for targets like PHP but the grammar "works" otherwise); add in parse tree comparison for all tests across all targets; finally, set up tests for performance across targets for selected grammars. It'll likely be a few weeks before performance tests are written.

@KvanTTT
Copy link
Member

KvanTTT commented Mar 4, 2023

I think it needs me to dedicate some serious time to write Go runtime tests in Go idiomatic form.

I'm not sure it's correct. We have several runtimes and ideally tests should be compatible with all of them. It's not idiomatic form but universal.

@parrt
Copy link
Member

parrt commented Mar 4, 2023

We definitely want to keep the general tests but you're free to make whatever extra tests you want in your runtime directories.

@jimidle
Copy link
Collaborator

jimidle commented Mar 5, 2023 via email

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.

4 participants