Permalink
Browse files

Added g:vim_addon_manager.*_hook_functions and addon-info.*-hook test…

…s without post-scms-update hook test

--HG--
branch : hooks
  • Loading branch information...
1 parent 5ef799e commit c4a5fb106941cb1a3a900a2c5407c67b533c1f6b @ZyX-I ZyX-I committed Feb 19, 2012
Showing with 88 additions and 2 deletions.
  1. +2 −2 autoload/vam/install.vim
  2. 0 test/hooks.in
  3. +40 −0 test/hooks.ok
  4. +46 −0 test/hooks.vim
View
@@ -327,7 +327,7 @@ fun! vam#install#UpdateAddon(name)
endif
let versionFile = pluginDir.'/version'
- let oldVersion = filereadable(versionFile) ? readfile(versionFile, 1)[0] : "?"
+ let oldVersion = filereadable(versionFile) ? readfile(versionFile, 'b')[0] : "?"
if oldVersion !=# newVersion || newVersion == '?'
" update plugin
echom "Updating plugin ".a:name." because ".(newVersion == '?' ? 'version is unknown' : 'there is a different version')
@@ -585,7 +585,7 @@ fun! vam#install#Checkout(targetDir, repository) abort
\ 'script-type': tolower(get(a:repository, 'script-type', 'plugin')),
\ 'unix_ff': get(a:repository, 'unix_ff', get(s:c, 'change_to_unix_ff')) })
- call writefile([get(a:repository,"version","?")], a:targetDir."/version")
+ call writefile([get(a:repository, 'version', '?')], a:targetDir.'/version', 'b')
endif
endfun
View
No changes.
View
@@ -0,0 +1,40 @@
+Hook: post-install
+info: []
+repo: [['type', 'archive'], ['url', 'http://downloads.sourceforge.net/project/vimpluginloader/vam-test/vam_test_tgz_2.tgz'], ['version', '0.1.7']]
+pdir: 'vam-hooks/vam_test_tgz2'
+opts: {}
+Hook: pre-update
+info: []
+repo: [['type', 'archive'], ['url', 'http://downloads.sourceforge.net/project/vimpluginloader/vam-test/vam_test_tgz_2-nodoc.tar.bz2'], ['version', '0.1.8']]
+pdir: 'vam-hooks/vam_test_tgz2'
+opts: {'oldVersion': '0.1.7'}
+Hook: post-update
+info: []
+repo: [['type', 'archive'], ['url', 'http://downloads.sourceforge.net/project/vimpluginloader/vam-test/vam_test_tgz_2-nodoc.tar.bz2'], ['version', '0.1.8']]
+pdir: 'vam-hooks/vam_test_tgz2'
+opts: {'oldVersion': '0.1.7'}
+Hook: post-install
+info: [['post-install-hook', 'call Hook(''post-install'', %i, %r, %d, %o)'], ['post-scms-update-hook', 'call Hook(''post-scms-update'', %i, %r, %d, %o)'], ['post-update-hook', 'call Hook(''post-update'', %i, %r, %d, %o)'], ['pre-update-hook', 'call Hook(''pre-update'', %i, %r, %d, %o)']]
+repo: [['type', 'archive'], ['url', 'http://downloads.sourceforge.net/project/vimpluginloader/vam-test/vam_test_hook.tar.bz2']]
+pdir: 'vam-hooks/vam_test_hook'
+opts: {}
+Plugin hook: post-install
+info: [['post-install-hook', 'call Hook(''post-install'', %i, %r, %d, %o)'], ['post-scms-update-hook', 'call Hook(''post-scms-update'', %i, %r, %d, %o)'], ['post-update-hook', 'call Hook(''post-update'', %i, %r, %d, %o)'], ['pre-update-hook', 'call Hook(''pre-update'', %i, %r, %d, %o)']]
+repo: [['type', 'archive'], ['url', 'http://downloads.sourceforge.net/project/vimpluginloader/vam-test/vam_test_hook.tar.bz2']]
+pdir: 'vam-hooks/vam_test_hook'
+opts: {}
+Hook: pre-update
+info: [['post-install-hook', 'call Hook(''post-install'', %i, %r, %d, %o)'], ['post-scms-update-hook', 'call Hook(''post-scms-update'', %i, %r, %d, %o)'], ['post-update-hook', 'call Hook(''post-update'', %i, %r, %d, %o)'], ['pre-update-hook', 'call Hook(''pre-update'', %i, %r, %d, %o)']]
+repo: [['type', 'archive'], ['url', 'http://downloads.sourceforge.net/project/vimpluginloader/vam-test/vam_test_hook.tar-copy.tar.bz2'], ['version', 'new']]
+pdir: 'vam-hooks/vam_test_hook'
+opts: {'oldVersion': '?'}
+Plugin hook: pre-update
+info: [['post-install-hook', 'call Hook(''post-install'', %i, %r, %d, %o)'], ['post-scms-update-hook', 'call Hook(''post-scms-update'', %i, %r, %d, %o)'], ['post-update-hook', 'call Hook(''post-update'', %i, %r, %d, %o)'], ['pre-update-hook', 'call Hook(''pre-update'', %i, %r, %d, %o)']]
+repo: [['type', 'archive'], ['url', 'http://downloads.sourceforge.net/project/vimpluginloader/vam-test/vam_test_hook.tar-copy.tar.bz2'], ['version', 'new']]
+pdir: 'vam-hooks/vam_test_hook'
+opts: {'oldVersion': '?'}
+Hook: post-update
+info: []
+repo: [['type', 'archive'], ['url', 'http://downloads.sourceforge.net/project/vimpluginloader/vam-test/vam_test_hook.tar-copy.tar.bz2'], ['version', 'new']]
+pdir: 'vam-hooks/vam_test_hook'
+opts: {'oldVersion': '?'}
View
@@ -0,0 +1,46 @@
+let s:F={}
+function s:F.hook_fun(info, repository, pluginDir, opts)
+ let pdir=fnamemodify(a:pluginDir, ':h:t').'/'.
+ \fnamemodify(a:pluginDir, ':t')
+ call WriteFile('info: '.string(sort(items(a:info))),
+ \ 'repo: '.string(sort(items(a:repository))),
+ \ 'pdir: '.string(pdir),
+ \ 'opts: '.string(a:opts))
+endfunction
+function s:F.pihook(...)
+ call WriteFile('Hook: post-install')
+ return call(s:F.hook_fun, a:000, {})
+endfunction
+function s:F.puhook(...)
+ call WriteFile('Hook: post-update')
+ return call(s:F.hook_fun, a:000, {})
+endfunction
+function s:F.Puhook(...)
+ call WriteFile('Hook: pre-update')
+ return call(s:F.hook_fun, a:000, {})
+endfunction
+function s:F.pUhook(...)
+ call WriteFile('Hook: post-scms-update')
+ return call(s:F.hook_fun, a:000, {})
+endfunction
+function Hook(hook, ...)
+ call WriteFile('Plugin hook: '.a:hook)
+ return call(s:F.hook_fun, a:000, {})
+endfunction
+let g:vim_addon_manager.post_install_hook_functions=[s:F.pihook]
+let g:vim_addon_manager.post_update_hook_functions=[s:F.puhook]
+let g:vim_addon_manager.pre_update_hook_functions=[s:F.Puhook]
+let g:vim_addon_manager.post_scms_update_hook_functions=[s:F.pUhook]
+call vam#ActivateAddons('vam_test_tgz2')
+UpdateActivatedAddons
+let desc=copy(g:vim_addon_manager.plugin_sources.vam_test_tgz2)
+let desc.version='0.1.8'
+let desc.url=desc.url[:-5].'-nodoc.tar.bz2'
+let patch={'vam_test_tgz2': desc}
+UpdateActivatedAddons
+call vam#ActivateAddons('vam_test_hook')
+let desc=copy(g:vim_addon_manager.plugin_sources.vam_test_hook)
+let desc.version='new'
+let desc.url=desc.url[:-5].'-copy.tar.bz2'
+let patch.vam_test_hook=desc
+UpdateActivatedAddons

0 comments on commit c4a5fb1

Please sign in to comment.