From b7311d9d04081028f272758c6a68a77f45b4b630 Mon Sep 17 00:00:00 2001 From: Iristyle Date: Tue, 13 Jun 2017 10:52:26 -0700 Subject: [PATCH] (maint) Switch AppVeyor to Ruby 2.4 from 2.3 - Now that RubyInstaller has produced an installer for Ruby 2.4.1 on Windows and AppVeyor has integrated it into their workflow per https://github.com/appveyor/ci/issues/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 https://github.com/puppetlabs/puppet/pull/5653 was the first pass in f4f5ccbbec53bd22d5b142cbe6f1615223cef418 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"]] --- appveyor.yml | 2 +- lib/puppet/indirector/file_bucket_file/file.rb | 1 + spec/unit/indirector/file_bucket_file/file_spec.rb | 2 +- spec/unit/util/run_mode_spec.rb | 10 +++++----- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5df87ab21fe..bfdcb3e0bf7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 diff --git a/lib/puppet/indirector/file_bucket_file/file.rb b/lib/puppet/indirector/file_bucket_file/file.rb index e55bdad61d6..8a8d18e676b 100644 --- a/lib/puppet/indirector/file_bucket_file/file.rb +++ b/lib/puppet/indirector/file_bucket_file/file.rb @@ -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 } diff --git a/spec/unit/indirector/file_bucket_file/file_spec.rb b/spec/unit/indirector/file_bucket_file/file_spec.rb index 6a4a2d3f9fa..f97c58712d0 100644 --- a/spec/unit/indirector/file_bucket_file/file_spec.rb +++ b/spec/unit/indirector/file_bucket_file/file_spec.rb @@ -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 diff --git a/spec/unit/util/run_mode_spec.rb b/spec/unit/util/run_mode_spec.rb index a024dbaac23..ae01005ae85 100644 --- a/spec/unit/util/run_mode_spec.rb +++ b/spec/unit/util/run_mode_spec.rb @@ -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 @@ -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 @@ -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 @@ -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 @@ -255,7 +255,7 @@ def self.gte_ruby_2_4 as_non_root { expect(@run_mode.run_dir).to eq(File.expand_path('~/.puppetlabs/var/run')) } end - it "fails when asking for the run_dir and there is no $HOME" do + it "fails when asking for the run_dir and there is no $HOME", :unless => gte_ruby_2_4 do as_non_root do without_env('HOME') do without_env('HOMEDRIVE') do