From 01c6a9e1753bd4b2166efe747151ba8700ebc0f5 Mon Sep 17 00:00:00 2001 From: Chef Expeditor Date: Thu, 11 Mar 2021 17:45:48 +0000 Subject: Move knife to its own gem This moves knife into /knife, in the same way that chef-utils and chef-config are separated. NOTES: == File History == If you see this message as the first message in the history of an knife file, you can see the complete history by using 'git log --follow', 'git config log.follow true' to make it the default behavior in this repository, or 'git config --globa log.follow true' to make it the global default. == API Changes == At the API level, there is one breaking change: CookbookSiteStreamingUploader has been moved out of chef and into knife/core. There were a combination of reasons we chose this path: - CookbookSiteStreamingUploader (CSSU) is only used within Knife. - CookbookSiteStreamingUploader (CSSU) references the command Chef::Knife::CookbookMetadata in order to generate a metadata file for the cookbook to upload - Chef::Knife::CookbookMetadata is no longer available to Chef:: because Knife has been moved to its own gem. Knife gem depends on the Chef gem, so Chef can't depend on something in Knife. A search for usage in related projects (berks, chef-cli) and the Internet at large shows that there are no known external consumers of CSSU. For now, we'll move this class into Knife::Core, as it's going to be faster than splitting off the metadata generation and time is a concern. If we find that we need the metadata generation in chef/ proper, we should evaluate decoupling that functionality from Knife::CookbookMetadata and exposing it via something like `Chef::Cookbook::Metadata#from_cookbook_files` == spec changes == The specs are kept in their existing locations, though we have separated out a `knife_spec_helper` so that we can ensure knife is not directly accessing chef requires; and chef is relying on knife's at all. We also now clear gem paths with each test, to force gem state to reset. This works around a problem where a combination of tests is corrupting the internal Gem state, causing failures in rubygems_spec. See branch `mp/broken-gems` for many more details around findings so far. Signed-off-by: Marc A. Paradise --- tasks/rspec.rb | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'tasks') diff --git a/tasks/rspec.rb b/tasks/rspec.rb index 929e0f91b0..050c40be5c 100644 --- a/tasks/rspec.rb +++ b/tasks/rspec.rb @@ -25,8 +25,9 @@ begin desc "Run specs for Chef's Gem Components" task :component_specs do - %w{chef-utils chef-config}.each do |gem| + %w{chef-utils chef-config knife}.each do |gem| Dir.chdir(gem) do + puts "--- Running #{gem} specs" Bundler.with_unbundled_env do sh("bundle install --jobs=3 --retry=3") sh("bundle exec rake spec") @@ -39,19 +40,24 @@ begin task spec: :component_specs - desc "Run all specs in spec directory" + desc "Run all chef specs in spec directory" RSpec::Core::RakeTask.new(:spec) do |t| t.verbose = false t.rspec_opts = %w{--profile} - t.pattern = FileList["spec/**/*_spec.rb"] + t.pattern = FileList["spec/**/*_spec.rb"].reject do |path| + path =~ /knife.*/ + end end namespace :spec do - desc "Run all specs in spec directory" + desc "Run all chef specs in spec directory" RSpec::Core::RakeTask.new(:all) do |t| t.verbose = false t.rspec_opts = %w{--profile} t.pattern = FileList["spec/**/*_spec.rb"] + t.pattern = FileList["spec/**/*_spec.rb"].reject do |path| + path =~ /knife.*/ + end end desc "Print Specdoc for all specs" @@ -61,7 +67,7 @@ begin t.pattern = FileList["spec/**/*_spec.rb"] end - desc "Run the specs under spec/unit with activesupport loaded" + desc "Run chef's node and role unit specs with activesupport loaded" RSpec::Core::RakeTask.new(:activesupport) do |t| t.verbose = false t.rspec_opts = %w{--require active_support/core_ext --profile} @@ -70,11 +76,13 @@ begin end %i{unit functional integration stress}.each do |sub| - desc "Run the specs under spec/#{sub}" + desc "Run the chef specs under spec/#{sub}" RSpec::Core::RakeTask.new(sub) do |t| t.verbose = false t.rspec_opts = %w{--profile} - t.pattern = FileList["spec/#{sub}/**/*_spec.rb"] + t.pattern = FileList["spec/#{sub}/**/*_spec.rb"].reject do |path| + path =~ /knife.*/ + end end end end -- cgit v1.2.1