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
Check test RBI files for well-formedness #554
Conversation
We don't get proper exit codes if `--quiet` is supplied. Ref: sorbet/sorbet#4761
ee1bfec
to
2775d2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about moving this as a service in RBI::File
, so it can be reused easily?
cmd << "--quiet" if quiet | ||
cmd |= args | ||
|
||
File.write("foo.rb", cmd.to_s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to write this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol, we don't. It is a left-over from my troubleshooting. 🤦
) | ||
|
||
assert($?.success?, <<~MSG) # rubocop:disable Style/SpecialGlobalVars | ||
Expected generated RBI file for `#{constant_name}` with no parsing errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Grammar is off with this sentence. Something like this is more clear:
Expected generated RBI file for `#{constant_name}` with no parsing errors. | |
Expected generated RBI file for `#{constant_name}` to not have any parsing errors. |
Motivation
@ryanwilsonperkin caught a problem with the RBI output in Active Record relations generator, which reminded me that we should be checking RBI files for well-formedness automatically in every test.
Implementation
After every RBI file is generated as a string, we pass it through Sorbet and just check the error-code. If there is an error, we show the Sorbet output which should help figure out the problem.
Tests
No automated test cases.