@@ -847,25 +847,55 @@ T['add()']['Install']['properly executes `*_install` hooks'] = function()
847
847
_G.process_mock_data = { [2] = { duration = 10 }, [3] = { duration = 5 } }
848
848
849
849
-- Add plugin with dependency and hooks
850
+ _G.args = {}
851
+ local make_hook = function(msg)
852
+ return function(...)
853
+ table.insert(_G.args, { msg, { ... } })
854
+ vim.notify(msg)
855
+ end
856
+ end
857
+
850
858
local dep_spec = {
851
859
source = 'user/dep_plugin',
852
860
hooks = {
853
- pre_install = function() vim.notify( 'Dependency pre_install') end ,
854
- post_install = function() vim.notify( 'Dependency post_install') end ,
861
+ pre_install = make_hook( 'Dependency pre_install'),
862
+ post_install = make_hook( 'Dependency post_install'),
855
863
},
856
864
}
857
865
local spec = {
858
866
source = 'user/new_plugin',
859
867
depends = { dep_spec },
860
868
hooks = {
861
- pre_install = function() vim.notify( 'Target pre_install') end ,
862
- post_install = function() vim.notify( 'Target post_install') end ,
869
+ pre_install = make_hook( 'Target pre_install'),
870
+ post_install = make_hook( 'Target post_install'),
863
871
},
864
872
}
865
873
866
874
MiniDeps.add(spec)
867
875
]] )
868
876
877
+ -- Should be called with proper arguments
878
+ local cwd_new_plugin , cwd_dep_plugin = test_opt_dir .. ' /new_plugin' , test_opt_dir .. ' /dep_plugin'
879
+ local ref_args = {
880
+ {
881
+ ' Dependency pre_install' ,
882
+ { { path = cwd_dep_plugin , source = ' https://github.com/user/dep_plugin' , name = ' dep_plugin' } },
883
+ },
884
+ {
885
+ ' Target pre_install' ,
886
+ { { path = cwd_new_plugin , source = ' https://github.com/user/new_plugin' , name = ' new_plugin' } },
887
+ },
888
+ {
889
+ ' Dependency post_install' ,
890
+ { { path = cwd_dep_plugin , source = ' https://github.com/user/dep_plugin' , name = ' dep_plugin' } },
891
+ },
892
+ {
893
+ ' Target post_install' ,
894
+ { { path = cwd_new_plugin , source = ' https://github.com/user/new_plugin' , name = ' new_plugin' } },
895
+ },
896
+ }
897
+ eq (child .lua_get (' _G.args' ), ref_args )
898
+
869
899
-- Should produce notifications
870
900
local ref_notify_log = {
871
901
-- Hooks are executed in a session order
@@ -1378,14 +1408,22 @@ end
1378
1408
1379
1409
T [' update()' ][' properly executes `*_checkout` hooks' ] = function ()
1380
1410
child .lua ([[
1381
- -- Add plugin with dependency and hooks
1411
+ -- Add plugins with hooks
1412
+ _G.args = {}
1413
+ local make_hook = function(msg)
1414
+ return function(...)
1415
+ table.insert(_G.args, { msg, { ... } })
1416
+ vim.notify(msg)
1417
+ end
1418
+ end
1419
+
1382
1420
for i = 1, 3 do
1383
1421
local name = 'plugin_' .. i
1384
1422
MiniDeps.add({
1385
1423
source = 'user/' .. name,
1386
1424
hooks = {
1387
- pre_checkout = function() vim.notify( name .. ' pre_checkout') end ,
1388
- post_checkout = function() vim.notify( name .. ' post_checkout') end ,
1425
+ pre_checkout = make_hook( name .. ' pre_checkout'),
1426
+ post_checkout = make_hook( name .. ' post_checkout'),
1389
1427
},
1390
1428
})
1391
1429
end
@@ -1420,6 +1458,28 @@ T['update()']['properly executes `*_checkout` hooks'] = function()
1420
1458
]] )
1421
1459
child .lua (' MiniDeps.update(nil, { force = true })' )
1422
1460
1461
+ -- Should be called with proper arguments
1462
+ local cwd_plugin_1 , cwd_plugin_2 = test_opt_dir .. ' /plugin_1' , test_opt_dir .. ' /plugin_2'
1463
+ local ref_args = {
1464
+ {
1465
+ ' plugin_1 pre_checkout' ,
1466
+ { { path = cwd_plugin_1 , source = ' https://github.com/user/plugin_1' , name = ' plugin_1' } },
1467
+ },
1468
+ {
1469
+ ' plugin_2 pre_checkout' ,
1470
+ { { path = cwd_plugin_2 , source = ' https://github.com/user/plugin_2' , name = ' plugin_2' } },
1471
+ },
1472
+ {
1473
+ ' plugin_1 post_checkout' ,
1474
+ { { path = cwd_plugin_1 , source = ' https://github.com/user/plugin_1' , name = ' plugin_1' } },
1475
+ },
1476
+ {
1477
+ ' plugin_2 post_checkout' ,
1478
+ { { path = cwd_plugin_2 , source = ' https://github.com/user/plugin_2' , name = ' plugin_2' } },
1479
+ },
1480
+ }
1481
+ eq (child .lua_get (' _G.args' ), ref_args )
1482
+
1423
1483
-- Should produce notifications
1424
1484
local ref_notify_log = {
1425
1485
{ ' (mini.deps) Downloading 3 updates' , ' INFO' },
0 commit comments