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

Allow library to be used with frozen-string-literals enabled. #590

Merged
merged 2 commits into from
Jun 24, 2017

Conversation

pat
Copy link
Contributor

@pat pat commented Jun 22, 2017

These changes ensure that all string literals can be frozen (as per the optional feature in MRI 2.3 and onwards).

I would recommend adding the following to your .travis.yml file to ensure regressions aren't introduced:

before_script:
- if (ruby -e "exit RUBY_VERSION.to_f >= 2.4"); then export RUBYOPT="--enable-frozen-string-literal"; fi; echo $RUBYOPT

This will add the flag when the tests are run on MRI 2.4 or newer (while the feature was introduced in 2.3, it doesn't seem to work reliably until 2.4). However, at this point in time for the tests to pass, you'll need to use the latest RSpec commits, along with submitted patches to simplecov-html, test-unit, and parser (for rubocop):

For the tests to pass, this requires the use of the latest RSpec commits, along with submitted patches to simplecov-html and test-unit:
* simplecov-ruby/simplecov-html#56
* test-unit/test-unit#149
Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

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

👋 Hello @pat thanks a lot and how are you doing? :D

That's great, thank you a lot! Although I guess I'll wait with running it in the test suite until all other libraries needed for this are released with fixes, but should file a follow up issue for this.

You seem to busy as a bunny supporting this in the ruby eco system, thanks a ton! 🎉

img_20170618_150728

@@ -1,5 +1,5 @@
module SimpleCov
version = "0.14.1"
version = "0.14.1".dup

def version.to_a
split(".").map(&:to_i)
Copy link
Collaborator

Choose a reason for hiding this comment

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

wait, whaaaaaat? I think I'd rather kill this code than introducing the .dup 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm not a fan either. Whatever you'd prefer for simplecov-ruby/simplecov-html#56, I'll do the same here as well.

@pat
Copy link
Contributor Author

pat commented Jun 22, 2017

Hullo @PragTob 👋 - and yes, I guess I have been busy patching all of the things! It's great to see that the latest test-unit is now frozen-string-literal friendly, so that's one dependency sorted :) Fingers crossed parser can get fixed up too and a new gem released - it's not possible to use it via a git repo due to Ragel-generated Ruby files.

Also, ensure it's always frozen, no matter which version or configuration of Ruby you're using.
@PragTob PragTob merged commit 03f4c55 into simplecov-ruby:master Jun 24, 2017
@PragTob
Copy link
Collaborator

PragTob commented Jun 24, 2017

Thanks a bunch @pat !

PragTob added a commit that referenced this pull request Jun 24, 2017
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Aug 31, 2017
0.15.0 (2017-08-14) ([changes](simplecov-ruby/simplecov@v0.14.1...v0.15.0))
=======

## Enhancements

* Ability to use regex filters for removing files from the output. See [#589](simplecov-ruby/simplecov#589) (thanks @jsteel)

## Bugfixes

* Fix merging race condition when running tests in parallel and merging
  them. See [#570](simplecov-ruby/simplecov#570) (thanks
  @jenseng)
* Fix relevant lines for unloaded files - comments, skipped code etc. are
  correctly classigied as irrelevant. See
  [#605](simplecov-ruby/simplecov#605) (thanks @odlp)
* Allow using simplecov with frozen-string-literals enabled. See
  [#590](simplecov-ruby/simplecov#590) (thanks @pat)
* Make sure Array Filter can use all other filter types. See
  [#589](simplecov-ruby/simplecov#589) (thanks @jsteel)
* Make sure file names use `Simplecov.root` as base avoiding using full
  absolute project paths. See
  [#589](simplecov-ruby/simplecov#589) (thanks @jsteel)
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.

2 participants