summaryrefslogtreecommitdiff
path: root/tasks/bin/run_external_test
blob: 1925c3e125317f8d8df2533c6887e3960584d54a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby

$:.unshift(File.expand_path("../../lib", File.dirname(__FILE__)))

require "tmpdir"
require "bundler"
require "chef/mixin/shell_out"

include Chef::Mixin::ShellOut

github_repo = ARGV.shift
git_thing = ARGV.shift

Dir.mktmpdir("chef-external-test") do |dir|
  git_url = "https://github.com/#{github_repo}"
  Dir.rmdir dir
  shell_out!("git clone #{git_url} #{dir}", live_stream: STDOUT)
  Dir.chdir(dir) do
    shell_out!("git checkout #{git_thing}", live_stream: STDOUT)
    Bundler.with_clean_env do
      shell_out!("bundle install", live_stream: STDOUT)
      shell_out!("bundle exec #{ARGV.join(" ")}", live_stream: STDOUT)
    end
  end
end