Skip to content

Commit

Permalink
fix fixtures_symlinks on Windows default tempdir
Browse files Browse the repository at this point in the history
use junction/mklink on windows to allow selfcontaining links
  • Loading branch information
tabakhase authored Apr 3, 2018
1 parent 9a3b0c9 commit 6717448
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 6717448

Please sign in to comment.