lib/vim-flavor/facade.rb in vim-flavor-1.0.0 vs lib/vim-flavor/facade.rb in vim-flavor-1.0.1
- old
+ new
@@ -1,10 +1,12 @@
require 'fileutils'
module Vim
module Flavor
class Facade
+ include ShellUtility
+
def trace message
print message
end
def refresh_flavors(mode, vimfiles_path)
@@ -18,11 +20,14 @@
mode
)
)
lockfile.save()
- deploy_flavors(lockfile.flavors, vimfiles_path)
+ deploy_flavors(
+ lockfile.flavors.select {|f| f.group == :runtime},
+ vimfiles_path.to_flavors_path
+ )
trace "Completed.\n"
end
def install(vimfiles_path)
@@ -59,31 +64,31 @@
end
completed_flavor_table
end
- def deploy_flavors(flavors, vimfiles_path)
+ def deploy_flavors(flavors, flavors_path)
trace "Deploying plugins...\n"
FileUtils.rm_rf(
- ["#{vimfiles_path.to_flavors_path}"],
+ [flavors_path],
:secure => true
)
- create_vim_script_for_bootstrap(vimfiles_path)
+ create_vim_script_for_bootstrap(flavors_path)
flavors.
before_each {|f| trace " #{f.repo_name} #{f.locked_version} ..."}.
after_each {|f| trace " done\n"}.
on_failure {trace " failed\n"}.
each do |f|
- f.deploy(vimfiles_path)
+ f.deploy(flavors_path)
end
end
- def create_vim_script_for_bootstrap(vimfiles_path)
- bootstrap_path = vimfiles_path.to_flavors_path.to_bootstrap_path
+ def create_vim_script_for_bootstrap(flavors_path)
+ bootstrap_path = flavors_path.to_bootstrap_path
FileUtils.mkdir_p(File.dirname(bootstrap_path))
File.open(bootstrap_path, 'w') do |f|
f.write(<<-'END')
function! s:bootstrap()
let current_rtp = &runtimepath
@@ -110,9 +115,48 @@
endfunction
call s:bootstrap()
END
end
+ end
+
+ def test()
+ trace "-------- Preparing dependencies\n"
+
+ flavorfile = FlavorFile.load_or_new(Dir.getwd().to_flavorfile_path)
+ flavorfile.flavor 'kana/vim-vspec', '~> 1.0', :group => :development unless
+ flavorfile.flavor_table.has_key?('kana/vim-vspec')
+ lockfile = LockFile.load_or_new(Dir.getwd().to_lockfile_path)
+
+ lockfile.update(
+ complete(
+ flavorfile.flavor_table,
+ lockfile.flavor_table,
+ :install
+ )
+ )
+ lockfile.save()
+
+ # FIXME: It's somewhat wasteful to refresh flavors every time.
+ deploy_flavors(
+ lockfile.flavors,
+ Dir.getwd().to_stash_path.to_deps_path
+ )
+
+ trace "-------- Testing a Vim plugin\n"
+
+ prove_options = '--comments --failure --directives'
+ deps_path = Dir.getwd().to_stash_path.to_deps_path
+ vspec = "#{deps_path}/#{'kana/vim-vspec'.zap}/bin/vspec"
+ plugin_paths = lockfile.flavors.map {|f|
+ "#{deps_path}/#{f.repo_name.zap}"
+ }
+ # FIXME: Testing messages are not outputted in real time.
+ print sh %Q{
+ prove --ext '.t' #{prove_options} &&
+ prove --ext '.vim' #{prove_options} \
+ --exec '#{vspec} #{Dir.getwd()} #{plugin_paths.join(' ')}'
+ }
end
end
end
end