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

Provide an abstract base class to be able to test the formatter. #2966

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

miklossy
Copy link
Contributor

@miklossy miklossy commented Mar 27, 2024

  • Add the org.eclipse.xtext.testing.AbstractFormatterTest class.
  • Modify the FormatterTest class of the Domainmodel example to demonstrate the usage of the AbstractFormatterTest class.
  • Modify the AbstractXtendFormatterTest base class to inherit from the newly created AbstractFormatterTest class and adapt the Xtend formatter test cases to use the inherited members/methods.

Closes #2965

@miklossy miklossy force-pushed the miklossy_formatter_abstract_base_class branch from 63f6418 to 538de85 Compare March 27, 2024 13:57
@LorenzoBettini
Copy link
Contributor

Just a comment about the CI failure: it looks like your PR is not based on the current master (it still uses Tycho 3 and old 4.31 builds.

@miklossy miklossy force-pushed the miklossy_formatter_abstract_base_class branch from 538de85 to 087f315 Compare March 28, 2024 06:58
@miklossy
Copy link
Contributor Author

Thanks for the hint @LorenzoBettini ! I have just rebased my feature branch on the master branch. Let's see if the CI bulid becomes green :-)

@miklossy
Copy link
Contributor Author

Seems the build is green now. @LorenzoBettini : could you please review my changes?

Copy link
Contributor

@LorenzoBettini LorenzoBettini left a comment

Choose a reason for hiding this comment

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

I'm fine with this proposal, though I'd like to have confirmation also from @szarnekow

Just a few other notes: I seem to remember that FormatterTestHelper provides other configurations. Do you think it could be useful to have additional assert methods in the base class accordingly?

Moreover, I think it would be important to use this base class also in other parts, e.g., in our formatter tests (Xbase, Xtend?) so that we're sure we use it during the CI. In fact, the Domainmodel is not tested in the CI of Xtext.

We could also have separate issues for the above.

@miklossy miklossy force-pushed the miklossy_formatter_abstract_base_class branch from 087f315 to a4d9485 Compare April 2, 2024 19:11
@miklossy
Copy link
Contributor Author

miklossy commented Apr 2, 2024

Thanks for your feedback @LorenzoBettini !

I'm fine with this proposal, though I'd like to have confirmation also from @szarnekow

I will request a review from @szarnekow as well.

Just a few other notes: I seem to remember that FormatterTestHelper provides other configurations. Do you think it could be useful to have additional assert methods in the base class accordingly?

I updated the PR so that the base class contains methods to configure the formatter preferences.

Moreover, I think it would be important to use this base class also in other parts, e.g., in our formatter tests (Xbase, Xtend?) so that we're sure we use it during the CI. In fact, the Domainmodel is not tested in the CI of Xtext.

I updated the Xtend Formatter test cases to use this new API class.

@miklossy miklossy added this to the Release_2.35 milestone Apr 3, 2024
Copy link
Contributor

@LorenzoBettini LorenzoBettini left a comment

Choose a reason for hiding this comment

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

I'm fine with the enhanced PR, thanks!

Just a comment/proposal: could we use the standard Java functional interfaces for the expected lambda instead of Procedures.Procedure1? I think Consumer would do, wouldn't it?

- Add the org.eclipse.xtext.testing.AbstractFormatterTest class.
- Modify the FormatterTest class of the Domainmodel example to
demonstrate the usage of the AbstractFormatterTest class.
- Modify the AbstractXtendFormatterTest base class to inherit from the
newly created AbstractFormatterTest class and adapt the Xtend formatter
test cases to use the inherited members/methods.

Signed-off-by: miklossy <miklossy@itemis.de>
@miklossy miklossy force-pushed the miklossy_formatter_abstract_base_class branch from a4d9485 to 7fe793a Compare April 3, 2024 07:48
@miklossy
Copy link
Contributor Author

miklossy commented Apr 3, 2024

Just a comment/proposal: could we use the standard Java functional interfaces for the expected lambda instead of Procedures.Procedure1? I think Consumer would do, wouldn't it?

Thanks for the feedback, @LorenzoBettini !
I have just updated the PR to use java.util.function.Consumer as suggested!

@LorenzoBettini
Copy link
Contributor

I have just updated the PR to use java.util.function.Consumer as suggested!

@miklossy great! :)

@miklossy miklossy merged commit 73bd158 into main Apr 17, 2024
10 checks passed
@miklossy miklossy deleted the miklossy_formatter_abstract_base_class branch April 17, 2024 08:31
@miklossy
Copy link
Contributor Author

Thanks for the review @LorenzoBettini : do you know where are the release notes prepared for Xtext 2.35 so that I can add some hints about this new API class?

@LorenzoBettini
Copy link
Contributor

Thanks for the review @LorenzoBettini : do you know where are the release notes prepared for Xtext 2.35 so that I can add some hints about this new API class?

Thank you for the contribution @miklossy .

Concerning release notes, let's hear from @cdietrich

@cdietrich
Copy link
Member

cdietrich commented Apr 17, 2024

please open a pr.

@LorenzoBettini can you create stubs for the new release notes

see also #2948

};
this._formatterTestHelper.assertFormatted(_function);
this.assertFormattedTo(_builder, _builder_1, _function);
Copy link
Contributor

Choose a reason for hiding this comment

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

@miklossy are you sure you committed all the generated files correctly? In my workspace, after using the new master with this PR merged, I get that this file should be

    final Consumer<MapBasedPreferenceValues> _function = (MapBasedPreferenceValues it) -> {

instead of the committed

    final Procedure1<MapBasedPreferenceValues> _function = (MapBasedPreferenceValues it) -> {

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 these changes too. can you open a fixing pr

Copy link
Contributor

Choose a reason for hiding this comment

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

LorenzoBettini added a commit that referenced this pull request Apr 20, 2024
concerning the changes applied here
#2966 (comment)
LorenzoBettini added a commit that referenced this pull request Apr 20, 2024
concerning the changes applied here
#2966 (comment)
@LorenzoBettini
Copy link
Contributor

please open a pr.

@LorenzoBettini can you create stubs for the new release notes

see also #2948

@cdietrich done: eclipse/xtext-website#33

hope I got it right because that's the first time

@LorenzoBettini
Copy link
Contributor

@miklossy the release notes files are in place eclipse/xtext-website#33 if you want to add some hints about the new classes

@miklossy
Copy link
Contributor Author

Thank you @LorenzoBettini ! I will definitely do!

@miklossy
Copy link
Contributor Author

@LorenzoBettini : I created the PR eclipse/xtext-website#34 about the hints.

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.

Provide an abstract base class to be able to test the formatter.
3 participants