From a3d39f4f2c181bf7b38031bd55fba1875c97c68d Mon Sep 17 00:00:00 2001 From: Daniel Lu Date: Thu, 7 Jul 2016 16:31:01 -0700 Subject: [PATCH 1/2] (PUP-6467) Fix Parallel Spec grouping for RSpec 3.5.0 Rspec_grouper currently tries to access an array of example groups through a private function children() in RSpec::Core::ExampleGroups in order to calculate example counts per spec file. With the RSpec 3.5.0 release, the example groups are no longer accessible through children(). So, rspec_grouper cannot find example groups and is reporting that no examples can be found. This commit uses RSpec.world.example_groups instead to access the array. --- Gemfile | 3 +-- util/rspec_grouper | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index f6d89f1c17c..99933841a84 100644 --- a/Gemfile +++ b/Gemfile @@ -29,8 +29,7 @@ gem "hiera", *location_for(ENV['HIERA_LOCATION'] || ['>= 2.0', '< 4']) gem "rake", "10.1.1", :require => false group(:development, :test) do - # RSpec 3.5.z is not compatible with parallel:spec. The version pin of '< 3.5.0', be removed once PUP-6466 is resolved - gem "rspec", "~> 3.1", "< 3.5.0", :require => false + gem "rspec", "~> 3.1", :require => false gem "rspec-its", "~> 1.1", :require => false gem "rspec-collection_matchers", "~> 1.1", :require => false gem "rspec-legacy_formatters", "~> 1.0", :require => false diff --git a/util/rspec_grouper b/util/rspec_grouper index 46c44fea762..fe8a31e4177 100755 --- a/util/rspec_grouper +++ b/util/rspec_grouper @@ -28,7 +28,7 @@ module Parallel # Populate a map of spec file => example count, sorted ascending by count # NOTE: this uses a private API of RSpec and is may break if the gem is updated - @files = ::RSpec::Core::ExampleGroup.children.inject({}) do |files, group| + @files = ::RSpec.world.example_groups.inject({}) do |files, group| file = group.metadata[:example_group_block].source_location[0] count = count_examples(group) files[file] = (files[file] || 0) + count From 96a916cb0296ecdbea5353e08484506dafa1b376 Mon Sep 17 00:00:00 2001 From: Daniel Lu Date: Thu, 7 Jul 2016 16:31:23 -0700 Subject: [PATCH 2/2] (maint) Reset Puppet version after version_spec tests During work on PUP-6467, it was found that some version_spec tests were modifying Puppet.version value globally, which was affecting tests in integration/indirector/facts/facter_spec.rb. Facter was incorrectly reporting a Puppet version of 1.2.3, instead of 4.6.0 during the tests, causing failures. This commit reverts Puppet.version to its original value after each test in version_spec. It also adds a context block and new test to clarify the functionality of the version setter. --- spec/unit/version_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/unit/version_spec.rb b/spec/unit/version_spec.rb index aa5e7d58198..513777405e6 100644 --- a/spec/unit/version_spec.rb +++ b/spec/unit/version_spec.rb @@ -4,6 +4,7 @@ describe "Puppet.version Public API" do before :each do + @current_ver = Puppet.version Puppet.instance_eval do if @puppet_version @puppet_version = nil @@ -11,6 +12,10 @@ end end + after :each do + Puppet.version = @current_ver + end + context "without a VERSION file" do before :each do Puppet.stubs(:read_version_file).returns(nil) @@ -39,4 +44,14 @@ expect(Puppet.version).to eq('1.2.3') end end + + context "Using version setter" do + it "does not read VERSION file if using set version" do + Puppet.expects(:read_version_file).never + Puppet.version = '1.2.3' + expect(Puppet.version).to eq('1.2.3') + end + end end + +