diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-05-22 12:55:30 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-05-22 12:55:30 -0400 |
commit | 849d61b5510b3a3449c2664cb5a702126a2f6e8b (patch) | |
tree | 2d3b10a780465dd63892f7590c20de3bc621a307 /test | |
parent | d8d159c123336ed0c2eac36fcca66c45633d0370 (diff) | |
parent | 114fd522308c8b4b66b8ff30b0a91b02e347db73 (diff) | |
download | rneovim-849d61b5510b3a3449c2664cb5a702126a2f6e8b.tar.gz rneovim-849d61b5510b3a3449c2664cb5a702126a2f6e8b.tar.bz2 rneovim-849d61b5510b3a3449c2664cb5a702126a2f6e8b.zip |
Merge pull request #4786 from jbradaric/vim-7.4.1516
vim-patch:7.4.1516,7.4.1521
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/file_perm_spec.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/functional/legacy/file_perm_spec.lua b/test/functional/legacy/file_perm_spec.lua new file mode 100644 index 0000000000..cabeecdc9c --- /dev/null +++ b/test/functional/legacy/file_perm_spec.lua @@ -0,0 +1,42 @@ +-- Test getting and setting file permissions. +require('os') + +local helpers = require('test.functional.helpers') +local clear, call, eq = helpers.clear, helpers.call, helpers.eq +local neq, exc_exec = helpers.neq, helpers.exc_exec + +describe('Test getting and setting file permissions', function() + local tempfile = os.tmpname() + + before_each(function() + os.remove(tempfile) + clear() + end) + + it('file permissions', function() + eq('', call('getfperm', tempfile)) + eq(0, call('setfperm', tempfile, 'r------')) + + call('writefile', {'one'}, tempfile) + eq(9, call('len', call('getfperm', tempfile))) + + eq(1, call('setfperm', tempfile, 'rwx------')) + if helpers.os_name == 'windows' then + eq('rw-rw-rw-', call('getfperm', tempfile)) + else + eq('rwx------', call('getfperm', tempfile)) + end + + eq(1, call('setfperm', tempfile, 'r--r--r--')) + eq('r--r--r--', call('getfperm', tempfile)) + + local err = exc_exec(('call setfperm("%s", "---")'):format(tempfile)) + neq(err:find('E475:'), nil) + + eq(1, call('setfperm', tempfile, 'rwx------')) + end) + + after_each(function() + os.remove(tempfile) + end) +end) |