Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PDK-636) Groundwork to allow PDK to persist downloaded fixtures #242

Merged
merged 3 commits into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/puppetlabs_spec_helper/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,19 @@
end
end

desc "Run spec tests in parallel and clean the fixtures directory if successful"
task :parallel_spec do |t, args|
begin
Rake::Task[:spec_prep].invoke
Rake::Task[:parallel_spec_standalone].invoke(*args.extras)
Rake::Task[:spec_clean].invoke
ensure
Rake::Task[:spec_clean_symlinks].invoke
end
end

desc "Parallel spec tests"
task :parallel_spec do
task :parallel_spec_standalone do |t, args|
raise 'Add the parallel_tests gem to Gemfile to enable this task' unless parallel_tests_loaded
if Rake::FileList[pattern].to_a.empty?
warn "No files for parallel_spec to run against"
Expand All @@ -77,11 +88,7 @@
args.push('--').concat(ENV['CI_SPEC_OPTIONS'].strip.split(' ')).push('--') unless ENV['CI_SPEC_OPTIONS'].nil? || ENV['CI_SPEC_OPTIONS'].strip.empty?
args.concat(Rake::FileList[pattern].to_a)

Rake::Task[:spec_prep].invoke
ParallelTests::CLI.new.run(args)
Rake::Task[:spec_clean].invoke
ensure
Rake::Task[:spec_clean_symlinks].invoke
end
end
end
Expand Down
23 changes: 21 additions & 2 deletions lib/puppetlabs_spec_helper/tasks/fixtures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ def clone_repo(scm, remote, target, subdir=nil, ref=nil, branch=nil, flags = nil
result
end

def update_repo(scm, target)
args = case scm
when 'hg'
['pull']
when 'git'
['fetch']
else
fail "Unfortunately #{scm} is not supported yet"
end
Dir.chdir(target) do
system("#{scm} #{args.flatten.join(' ')}")
end
end

def revision(scm, target, ref)
args = []
case scm
Expand Down Expand Up @@ -239,7 +253,11 @@ def check_directory_for_symlinks(dir='.')
logger.debug "New Thread started for #{remote}"
# start up a new thread and store it in the opts hash
opts[:thread] = Thread.new do
clone_repo(scm, remote, target, subdir, ref, branch, flags)
if File.directory?(target)
update_repo(scm, target)
else
clone_repo(scm, remote, target, subdir, ref, branch, flags)
end
revision(scm, target, ref) if ref
remove_subdirectory(target, subdir) if subdir
end
Expand Down Expand Up @@ -283,7 +301,8 @@ def check_directory_for_symlinks(dir='.')
ref = " --version #{opts['ref']}" if not opts['ref'].nil?
flags = " #{opts['flags']}" if opts['flags']
end
next if File::exists?(target)

next if File.directory?(target)

working_dir = module_working_directory
target_dir = File.expand_path('spec/fixtures/modules')
Expand Down