Skip to content

Commit 568329f

Browse files
Merge #701
701: Get tests passing with frozen-string-literals enabled. r=badboy This one simple change ensure that all string literals can be frozen (as per the optional feature in MRI 2.3 and onwards). @twalpole has (again) beaten me to such a patch (in #590), though mine (again) does not add the pragma comment to all files. Getting their or my PRs merged in would be excellent :) As an alternative to the pragma comment, I would recommend adding the following to your .travis.yml file to ensure regressions aren't introduced: ```yml 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). Please note: tests will currently fail when this flag is set unless test-unit is also updated (as noted in test-unit/test-unit#149).
2 parents 20913ff + 8033911 commit 568329f

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ rvm:
77
- 2.1
88
- 2.2
99
- 2.3.0
10+
- 2.4.1
1011
- jruby-18mode
1112
- jruby-19mode
1213
- jruby-9.0.5.0
@@ -16,6 +17,9 @@ gemfile: ".travis/Gemfile"
1617

1718
sudo: false
1819

20+
before_script:
21+
- if (ruby -e "exit RUBY_VERSION.to_f >= 2.4"); then export RUBYOPT="--enable-frozen-string-literal"; fi; echo $RUBYOPT
22+
1923
env:
2024
global:
2125
- VERBOSE=true

.travis/Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ when "synchrony"
99
gem "hiredis"
1010
gem "em-synchrony"
1111
end
12+
13+
if RUBY_VERSION.to_f < 1.9
14+
gem 'test-unit', '3.1.5'
15+
else
16+
gem 'test-unit', '>= 3.2.5'
17+
end

Gemfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
source 'https://rubygems.org'
33

44
gemspec
5+
6+
if RUBY_VERSION.to_f < 1.9
7+
gem 'test-unit', '3.1.5'
8+
else
9+
gem 'test-unit', '>= 3.2.5'
10+
end

lib/redis/connection/ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def initialize(*args)
3939
super(*args)
4040

4141
@timeout = @write_timeout = nil
42-
@buffer = ""
42+
@buffer = "".dup
4343
end
4444

4545
def timeout=(timeout)

redis.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ Gem::Specification.new do |s|
4040
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
4141

4242
s.add_development_dependency("rake", "<11.0.0")
43-
s.add_development_dependency("test-unit", "3.1.5")
43+
s.add_development_dependency("test-unit", ">= 3.1.5")
4444
end

0 commit comments

Comments
 (0)