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

Check test RBI files for well-formedness #554

Closed
wants to merge 2 commits into from

Conversation

paracycle
Copy link
Member

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.

We don't get proper exit codes if `--quiet` is supplied. Ref: sorbet/sorbet#4761
@paracycle paracycle requested a review from a team October 20, 2021 17:35
@paracycle paracycle force-pushed the uk-check-dsl-rbi-files-for-parse-errors branch from ee1bfec to 2775d2b Compare October 20, 2021 17:36
Copy link
Collaborator

@Morriar Morriar left a 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)
Copy link
Member

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?

Copy link
Member Author

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.
Copy link
Contributor

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:

Suggested change
Expected generated RBI file for `#{constant_name}` with no parsing errors.
Expected generated RBI file for `#{constant_name}` to not have any parsing errors.

@paracycle paracycle marked this pull request as draft October 25, 2021 15:05
@Morriar Morriar added the enhancement New feature or request label Oct 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants