robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , before_each , after_each =t . describe , t . it , t . before_each , t . after_each 5local clear =n . clear 6local eq =t . eq 7local exec_lua =n . exec_lua 8local is_os =t . is_os 9local pathsep =n . get_pathsep () 10local write_file =t . write_file 11 12describe ( ':log' , function () 13local xstate ='Xstate' 14local name =( is_os ( 'win' ) and 'nvim-data' or 'nvim' ) 15 16before_each ( function () 17clear { env ={ XDG_STATE_HOME =xstate } } 18 19local std_state =xstate .. pathsep .. name 20n . mkdir_p ( std_state .. pathsep .. 'logs' ) 21write_file ( std_state .. '/logs/nvim.log' , [[nvim log]] ) 22write_file ( std_state .. '/logs/foo.log' , [[foo log]] ) 23end ) 24 25after_each ( function () 26n . rmdir ( xstate ) 27end ) 28 29it ( 'without argument opens log folder' , function () 30eq ( 31xstate .. '/' .. name .. '/logs' , 32exec_lua ( function () 33vim . cmd ( 'log' ) 34return vim . fs . normalize ( vim . fn . expand ( '%' )) 35end ) 36) 37end ) 38 39it ( 'with argument opens corresponding log file' , function () 40eq ( 41xstate .. '/' .. name .. '/logs/foo.log' , 42exec_lua ( function () 43vim . cmd ( 'log foo' ) 44return vim . fs . normalize ( vim . fn . expand ( '%' )) 45end ) 46) 47end ) 48 49it ( 'nvim works with non-default $NVIM_LOG_FILE' , function () 50clear { env ={ XDG_STATE_HOME =xstate , NVIM_LOG_FILE ='Xfoo.log' } } 51write_file ( 'Xfoo.log' , [[nvim log]] ) 52eq ( 53'Xfoo.log' , 54exec_lua ( function () 55vim . cmd ( 'log nvim' ) 56return vim . fn . expand ( '%' ) 57end ) 58) 59end ) 60 61it ( 'argument completion' , function () 62local completions =exec_lua ( function () 63return vim . fn . getcompletion ( 'log ' , 'cmdline' ) 64end ) 65eq ( { 'foo' , 'nvim' } , completions ) 66end ) 67 68it ( 'works without runtime' , function () 69clear { 70args_rm ={ '-u' } , 71args ={ '-u' , 'NONE' } , 72env ={ VIMRUNTIME ='non-existent' } , 73} 74exec_lua ( function () 75vim . cmd ( 'log' ) 76end ) 77end ) 78end )