Skip to content

Commit

Permalink
(maint) Switch AppVeyor to Ruby 2.4 from 2.3
Browse files Browse the repository at this point in the history
 - Now that RubyInstaller has produced an installer for Ruby 2.4.1 on
   Windows and AppVeyor has integrated it into their workflow per
   appveyor/ci#1350 we can move from 2.3 to
   2.4 given Puppet 5 will be shipping against 2.4

 - Update tests that behave differently under Ruby 2.4:

   * Ruby has changed how ~ resolves when no HOME, HOMEDRIVE or
     USERPROFILE has set. It no longer fails to resolve / causes an
     exception thanks to https://bugs.ruby-lang.org/issues/12695

     puppetlabs#5653 was the first pass
     in f4f5ccb but was incomplete.

   * Ruby has changed the implementation of sort_by! so that items
     already in order will not be returned in the same order. For
     instance, compare the behaviors between Ruby 2.3 and 2.4:

     [[1.0, 'a'], [1.0, 'b'], [1.0, 'c']].sort_by! { |i| i[0] }
       Ruby 2.3:
       [[1.0, "a"], [1.0, "b"], [1.0, "c"]]
       Ruby 2.4:
       [[1.0, "b"], [1.0, "c"], [1.0, "a"]]

     [[1.0, 'c'], [1.0, 'b'], [1.0, 'a']].sort_by! { |i| i[0] }
       Ruby 2.3:
       [[1.0, "c"], [1.0, "b"], [1.0, "a"]]
       Ruby 2.4:
       [[1.0, "b"], [1.0, "a"], [1.0, "c"]]
  • Loading branch information
Iristyle committed Jun 14, 2017
1 parent 27fdad2 commit 32c21ff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ matrix:

# Ruby versions under test
platform:
- Ruby23-x64
- Ruby24-x64
- Ruby21-x64

# Note that locales are mainly code page changes and are not the FULL set of localization
Expand Down
1 change: 1 addition & 0 deletions lib/puppet/indirector/file_bucket_file/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def list(request)
# Sort the results
bucket.each { |filename, contents|
contents.sort_by! do |item|
# NOTE: Ruby 2.4 may reshuffle item order even if the keys in sequence are sorted already
item[0]
end
}
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/indirector/file_bucket_file/file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def save_bucket_file(contents, path = "/who_cares")

# The list is sort order from date and file name, so first and third checksums come before the second
date_pattern = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}'
expect(find_result.to_s).to match(Regexp.new("^#{checksum1} #{date_pattern} foo/bar1\\n#{checksum3} #{date_pattern} foo/bar1\\n#{checksum2} #{date_pattern} foo/bar2\\n$"))
expect(find_result.to_s).to match(Regexp.new("^(#{checksum1}|#{checksum3}) #{date_pattern} foo/bar1\\n(#{checksum3}|#{checksum1}) #{date_pattern} foo/bar1\\n#{checksum2} #{date_pattern} foo/bar2\\n$"))
end

it "should fail in an informative way when provided dates are not in the right format" do
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/util/run_mode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def self.gte_ruby_2_4
as_non_root { expect(@run_mode.conf_dir).to eq(File.expand_path("~/.puppetlabs/etc/puppet")) }
end

it "fails when asking for the conf_dir as non-root and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%" do
it "fails when asking for the conf_dir as non-root and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%", :unless => gte_ruby_2_4 do
as_non_root do
without_env('HOME') do
without_env('HOMEDRIVE') do
Expand All @@ -182,7 +182,7 @@ def self.gte_ruby_2_4
as_non_root { expect(@run_mode.code_dir).to eq(File.expand_path("~/.puppetlabs/etc/code")) }
end

it "fails when asking for the code_dir as non-root and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%" do
it "fails when asking for the code_dir as non-root and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%", :unless => gte_ruby_2_4 do
as_non_root do
without_env('HOME') do
without_env('HOMEDRIVE') do
Expand All @@ -204,7 +204,7 @@ def self.gte_ruby_2_4
as_non_root { expect(@run_mode.var_dir).to eq(File.expand_path("~/.puppetlabs/opt/puppet/cache")) }
end

it "fails when asking for the conf_dir as non-root and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%" do
it "fails when asking for the conf_dir as non-root and there is no %HOME%, %HOMEDRIVE%, and %USERPROFILE%", :unless => gte_ruby_2_4 do
as_non_root do
without_env('HOME') do
without_env('HOMEDRIVE') do
Expand All @@ -229,7 +229,7 @@ def self.gte_ruby_2_4
as_non_root { expect(@run_mode.log_dir).to eq(File.expand_path('~/.puppetlabs/var/log')) }
end

it "fails when asking for the log_dir and there is no $HOME" do
it "fails when asking for the log_dir and there is no $HOME", :unless => gte_ruby_2_4 do
as_non_root do
without_env('HOME') do
without_env('HOMEDRIVE') do
Expand Down

0 comments on commit 32c21ff

Please sign in to comment.