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

Added logic adding/not adding empty lines when formatting specs based on flag/settings. #2692

Conversation

jensakejohansson
Copy link
Contributor

@jensakejohansson jensakejohansson commented Feb 3, 2025

  1. Added a flag that makes it optional if you want the formatter to add empty lines around tags & before table definitions in the spec-files.
  2. Implementation in server to handle requests from extension regarding changes in settings.json, where you can define the formatters behavior.
  3. settings.go hold the 'state' of settings on the server-side, which can extended to hold any other settings added in the future.

To make it work fully a few lines needs to be in the VSC Extension as well, but I hold that until I know if this will be considered.

Further description in issue:
#2693

…receiving settings from VSC Extension.

Signed-off-by: Jens Johansson <jens.johansson@systemverification.com>
Copy link
Contributor

github-actions bot commented Feb 3, 2025

Benchmark Results

java_maven_multithreaded.csv

Commit CPU Memory Time ExitCode
5884aa1 64% 174356 0:13.96 0
c779a46 57% 169132 0:15.94 0
ce9a5a9 69% 205012 0:15.45 0
d592a82 62% 192860 0:17.34 0

java_simple_serial.csv

Commit CPU Memory Time ExitCode
5884aa1 53% 67836 0:12.38 0
c779a46 53% 68644 0:11.71 0
ce9a5a9 47% 65048 0:13.94 0
d592a82 55% 64684 0:11.80 0

java_maven_serial.csv

Commit CPU Memory Time ExitCode
5884aa1 67% 190804 0:18.02 0
c779a46 74% 190000 0:16.19 0
ce9a5a9 77% 219096 0:17.32 0
d592a82 75% 218420 0:17.91 0

java_simple_multithreaded.csv

Commit CPU Memory Time ExitCode
5884aa1 38% 70512 0:09.70 0
c779a46 38% 68908 0:09.60 0
ce9a5a9 32% 63300 0:11.93 0
d592a82 40% 65012 0:09.25 0

java_simple_parallel.csv

Commit CPU Memory Time ExitCode
5884aa1 24% 74792 0:24.36 0
c779a46 24% 74856 0:23.53 0
ce9a5a9 22% 66848 0:24.94 0
d592a82 22% 66956 0:24.69 0

java_gradle_multithreaded.csv

Commit CPU Memory Time ExitCode
5884aa1 10% 125920 0:22.82 0
c779a46 9% 115856 0:23.52 0
ce9a5a9 9% 122104 0:24.84 0
d592a82 9% 113836 0:22.94 0

java_gradle_serial.csv

Commit CPU Memory Time ExitCode
5884aa1 10% 104040 0:24.67 0
c779a46 10% 120672 0:25.37 0
ce9a5a9 10% 124892 0:25.89 0
d592a82 9% 124468 0:24.94 0

java_gradle_parallel.csv

Commit CPU Memory Time ExitCode
5884aa1 5% 107148 0:44.76 0
c779a46 5% 102904 0:41.45 0
ce9a5a9 6% 129980 0:47.00 0
d592a82 5% 111688 0:46.23 0

java_maven_parallel.csv

Commit CPU Memory Time ExitCode
5884aa1 35% 170296 0:31.54 0
c779a46 34% 183044 0:32.88 0
ce9a5a9 34% 189984 0:35.83 0
d592a82 35% 206056 0:34.23 0

Notes

  • The results above are generated by running against seed projects in https://github.com/getgauge/gauge-benchmark
  • These results are not persisted, but on merging to master the benchmark will be rerun.
  • These benchmark are run in Github Actions' agents, which are virtualized. Results are not to be taken as actual benchmarks.Rather, these are indicative numbers and make sense for comparison.

See Workflow log for more details.

Copy link
Member

@sriv sriv left a comment

Choose a reason for hiding this comment

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

Looks good, perhaps you could add a test or two? - https://github.com/getgauge/gauge/blob/master/formatter/formatter_test.go

I am ok to merge this even without a test, but just thought I'd mention this in case this was an oversight :)

And I get your point around preferences. Readability is a good enough reason for me!

…receiving settings from VSC Extension.

Signed-off-by: Jens Johansson <jens.johansson@systemverification.com>
sriv
sriv previously approved these changes Feb 3, 2025
@jensakejohansson
Copy link
Contributor Author

Thanks @sriv! No, I did not forget about tests, just waited if you would disregard the change immediately :)
3 Updates in test-file for formatter:

  1. Introduced a setup-method called before each test that makes sure the setting SetSkipEmptyLineInsertions = false before any test starts.
  2. Updated existing tests to also include tags, to make sure that is formatted correctly in the "default" behaviour. Now I saw that it actually was a special test already for that, but well... I'll let it be now.
  3. Added a new test that formats a scenario with the new flag set to true and makes sure it doesn't add any empty lines to spec.

@gaugebot
Copy link

gaugebot bot commented Feb 3, 2025

@jensakejohansson Thank you for contributing to gauge. Your pull request has been labeled as a release candidate 🎉🎉.

Merging this PR will trigger a release.

Please bump up the version as part of this PR.

Instructions to bump the version can found at CONTRIBUTING.md

If the CONTRIBUTING.md file does not exist or does not include instructions about bumping up the version, please looks previous commits in git history to see what changes need to be done.

@sriv
Copy link
Member

sriv commented Feb 3, 2025

Cool! I've labelled this as a release candidate. If you could just bump the version up I'll merge it right away.

…receiving settings from VSC Extension.

Signed-off-by: Jens Johansson <jens.johansson@systemverification.com>
@jensakejohansson
Copy link
Contributor Author

Great, I've made a commit now where I updated to version 1.6.13. 👍

@sriv sriv enabled auto-merge (squash) February 3, 2025 15:37
@jensakejohansson
Copy link
Contributor Author

Can you merge it now? Seems like an approval is missing.

@sriv sriv merged commit 706e32a into getgauge:master Feb 3, 2025
28 checks passed
@jensakejohansson jensakejohansson deleted the formatter-skip-empty-lines-insertions branch February 3, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants