Skip to content

Updates for frozen-string-literal compatibility.

gitlab-qa-bot requested to merge github/fork/pat/frozen-string-literals into master

Created by: pat

(I've got patches for rspec-expectations, rspec-mocks and rspec-support which are related to this one, so I'm going to write out all the detail here, and then link to it from the others.)

I've put together these patches by running the test suites for each gem with the RUBYOPT=--enable-frozen-string-literal flag, so they're more thorough than my previous patches on this topic. However, as noted in those previous discussions, the test suite cannot yet be run reliably in that situation, so I've had some local changes to my Gemfile, and worked on patches for some dependencies. I've also had to have all rspec-x repos locally to debug some of the fixes in these patches.

Also: I've not got the cucumber test suites working in rspec-core, rspec-expectations, or rspec-mocks, so there could very well be further places in the Spec codebase that need changing. You're using a two-year-old version of Cucumber (1.3.x, when 2.x is released and 3.x is on the way), so I'm not sure how much effort should be put into updating that? Should we fork the 1.3.x release and make that frozen-string-literal-safe? Although, there are issues in Cucumber's dependencies as well…

Regarding how I've patched things: generally, I'm using dup instead of String.new - this is mostly because I've been working on similar patches for Rails, and the maintainers there prefer dup, hence that's my current habit. Also, String.new has an ASCII encoding, whereas String.new('some string') respects the argument's encoding (which defaults to UTF in recent Rubies), and that inconsistency is annoying.

I could (and might) keep going down the dependency rabbit hole and offer further patches, but I wanted to at least get these changes submitted so they're useful for the RSpec team sooner rather than later.

The dependency situation as it currently stands:

Patched (albeit with no new versions yet):

Pull Requests submitted:

In-progress patches:

  • racc (used by parser)

No known patches:

  • cucumber
  • aruba (used by cucumber)
  • syntax (used by cucumber)
  • Possibly more, related to cucumber?

For anyone wanting to help: if you have commit bits on any of the above dependency repos, maybe get outstanding PRs merged, or help investigate failing test suites (racc). If anyone's on the Cucumber team: discussions need to be had around updating the version of Aruba it's dependant on, and maybe migrating from Syntax to Coderay (as that's what's recommended in the Syntax README).

Merge request reports