Skip to content

Commit

Permalink
Merge pull request #167 from tabakhase/patch-2
Browse files Browse the repository at this point in the history
fix fixtures_symlinks on Windows default tempdir
  • Loading branch information
dylanratcliffe authored Apr 5, 2018
2 parents 0b8e624 + f6556b5 commit 2e90f21
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/onceover/testconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,22 @@ def create_fixtures_symlinks(repo)
repo.temp_modulepath.split(':').each do |path|
Dir["#{path}/*"].each do |mod|
modulename = File.basename(mod)
logger.debug "Symlinking #{mod} to #{repo.tempdir}/spec/fixtures/modules/#{modulename}"
FileUtils.ln_s(mod, "#{repo.tempdir}/spec/fixtures/modules/#{modulename}")
link = "#{repo.tempdir}/spec/fixtures/modules/#{modulename}"
logger.debug "Symlinking #{mod} to #{link}"
unless File.symlink?(link)
# Ruby only sets File::ALT_SEPARATOR on Windows and Rubys standard library
# uses this to check for Windows
if !!File::ALT_SEPARATOR
mod = File.join(File.dirname(link), mod) unless Pathname.new(mod).absolute?
if Dir.respond_to?(:create_junction)
Dir.create_junction(link, mod)
else
system("call mklink /J \"#{link.gsub('/', '\\')}\" \"#{mod.gsub('/', '\\')}\"")
end
else
FileUtils.ln_s(mod, link)
end
end
end
end
end
Expand Down

0 comments on commit 2e90f21

Please sign in to comment.