robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
4edeaaa6e2
master
1" Test getting and setting file permissions. 2 3func Test_file_perm () 4call assert_equal ( '' , getfperm ( 'XtestPerm' )) 5call assert_equal ( 0 , 'XtestPerm' ->setfperm ( 'r--------' )) 6 7call writefile ([ 'one' ], 'XtestPerm' , 'D' ) 8call assert_true ( len ( 'XtestPerm' ->getfperm ()) == 9 ) 9 10call assert_equal ( 1 , setfperm ( 'XtestPerm' , 'rwx------' )) 11if has ( 'win32' ) 12call assert_equal ( 'rw-rw-rw-' , getfperm ( 'XtestPerm' )) 13else 14call assert_equal ( 'rwx------' , getfperm ( 'XtestPerm' )) 15endif 16 17call assert_equal ( 1 , setfperm ( 'XtestPerm' , 'r--r--r--' )) 18call assert_equal ( 'r--r--r--' , getfperm ( 'XtestPerm' )) 19 20call assert_fails ( "call setfperm('XtestPerm', '---')" , 'E475: Invalid argument: ---' ) 21 22call assert_equal ( 1 , setfperm ( 'XtestPerm' , 'rwx------' )) 23 24call assert_fails ( "call setfperm(['Xpermfile'], 'rw-rw-rw-')" , 'E730:' ) 25call assert_fails ( "call setfperm('Xpermfile', [])" , 'E730:' ) 26call assert_fails ( "call setfperm('Xpermfile', 'rwxrwxrwxrw')" , 'E475:' ) 27endfunc 28 29" vim: shiftwidth=2 sts=2 expandtab