diff options
author | John Keiser <john@johnkeiser.com> | 2016-04-12 16:04:27 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-04-18 14:21:02 -0700 |
commit | bbc1d6ebccbd7f22fea72a9c2b76ef19f3b5beb3 (patch) | |
tree | 97bd064d63268eb7ff39e1b4416abdff42ad0f34 /tasks/external_tests.rb | |
parent | 612932e984e4a210891e5d2d00d25723afd6b6a4 (diff) | |
download | chef-bbc1d6ebccbd7f22fea72a9c2b76ef19f3b5beb3.tar.gz |
Simplify external tests and make them work with Gemfile.lock
Diffstat (limited to 'tasks/external_tests.rb')
-rw-r--r-- | tasks/external_tests.rb | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/tasks/external_tests.rb b/tasks/external_tests.rb deleted file mode 100644 index a909ec2178..0000000000 --- a/tasks/external_tests.rb +++ /dev/null @@ -1,64 +0,0 @@ -require "tempfile" -require "bundler" - -CURRENT_GEM_NAME = "chef" -CURRENT_GEM_PATH = File.expand_path("../..", __FILE__) - -def bundle_exec_with_chef(test_gem, commands) - gem_path = Bundler.environment.specs[test_gem].first.full_gem_path - gemfile_path = File.join(gem_path, "Gemfile.#{CURRENT_GEM_NAME}-external-test") - gemfile = File.open(gemfile_path, "w") - begin - IO.read(File.join(gem_path, "Gemfile")).each_line do |line| - if line =~ /^\s*gemspec/ - next - elsif line =~ /^\s*gem '#{CURRENT_GEM_NAME}'|\s*gem "#{CURRENT_GEM_NAME}"/ - next - elsif line =~ /^\s*dev_gem\s*['"](.+)['"]\s*$/ - line = "gem '#{$1}', github: 'poise/#{$1}'" - elsif line =~ /\s*gem\s*['"]#{test_gem}['"]/ # foodcritic end - next - end - gemfile.puts(line) - end - gemfile.puts("gem #{CURRENT_GEM_NAME.inspect}, path: #{CURRENT_GEM_PATH.inspect}") - gemfile.puts("gemspec path: #{gem_path.inspect}") - gemfile.close - Dir.chdir(gem_path) do - Bundler.with_clean_env do - unless system({ "BUNDLE_GEMFILE" => gemfile_path, "RUBYOPT" => nil, "GEMFILE_MOD" => nil }, "bundle update") - raise "Error running bundle update of #{gemfile_path} in #{gem_path}: #{$?.exitstatus}\nGemfile:\n#{IO.read(gemfile_path)}" - end - Array(commands).each do |command| - unless system({ "BUNDLE_GEMFILE" => gemfile_path, "RUBYOPT" => nil, "GEMFILE_MOD" => nil }, "bundle exec #{command}") - raise "Error running bundle exec #{command} in #{gem_path} with BUNDLE_GEMFILE=#{gemfile_path}: #{$?.exitstatus}\nGemfile:\n#{IO.read(gemfile_path)}" - end - end - end - end - ensure - File.delete(gemfile_path) if File.exist?(gemfile_path) - end -end - -EXTERNAL_PROJECTS = { - "chef-zero" => [ "rake spec", "rake cheffs" ], - "cheffish" => "rake spec", - "chef-provisioning" => "rake spec", - "chef-provisioning-aws" => "rake spec", - "chef-sugar" => "rake", - "foodcritic" => "rake test", - "chefspec" => "rake", - "chef-rewind" => "rake spec", - "poise" => "rake spec", - "halite" => "rake spec", - "knife-windows" => "rake unit_spec", -} - -task :external_specs => EXTERNAL_PROJECTS.keys.map { |g| :"#{g.sub("-", "_")}_spec" } - -EXTERNAL_PROJECTS.each do |test_gem, commands| - task :"#{test_gem.tr("-", "_")}_spec" do - bundle_exec_with_chef(test_gem, commands) - end -end |