diff options
author | Will Spurgin <will.spurgin@gmail.com> | 2022-11-04 20:24:34 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-05 09:24:34 +0800 |
commit | 19a487bc86482392eb50c61375d20e440e6e16b7 (patch) | |
tree | 7ca39ed9bc728dc1e6e3c8ed6c83679e220e1da8 /test/functional/core/fileio_spec.lua | |
parent | 95f2f3cb5efcc18f17f2812ba6d1d9e1c06b2b5a (diff) | |
download | rneovim-19a487bc86482392eb50c61375d20e440e6e16b7.tar.gz rneovim-19a487bc86482392eb50c61375d20e440e6e16b7.tar.bz2 rneovim-19a487bc86482392eb50c61375d20e440e6e16b7.zip |
fix(fileio): use first available directory in backupdir for backupcopy (#20655)
Fix backups failing for symlink files
Set backup to NULL prior to continuing & Clear backup prior to NULL set
to avoid leaking
Fixes #11349
Remove testing hacks in scripts for windows
Skip FreeBSD
Something appears up with these types of tests for FreeBSD on
Circus, see 2d6735d8ce
Diffstat (limited to 'test/functional/core/fileio_spec.lua')
-rw-r--r-- | test/functional/core/fileio_spec.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index 07774866a8..795f639dad 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -1,3 +1,4 @@ +local lfs = require('lfs') local helpers = require('test.functional.helpers')(after_each) local assert_log = helpers.assert_log @@ -5,6 +6,7 @@ local assert_nolog = helpers.assert_nolog local clear = helpers.clear local command = helpers.command local eq = helpers.eq +local neq = helpers.neq local ok = helpers.ok local feed = helpers.feed local funcs = helpers.funcs @@ -132,6 +134,57 @@ describe('fileio', function() eq('foo', foo_contents); end) + it('backup symlinked files #11349', function() + if isCI('cirrus') then + pending('FIXME: cirrus') + end + clear() + + local initial_content = 'foo' + local link_file_name = 'Xtest_startup_file2' + local backup_file_name = link_file_name .. '~' + + write_file('Xtest_startup_file1', initial_content, false) + lfs.link('Xtest_startup_file1', link_file_name, true) + command('set backup') + command('set backupcopy=yes') + command('edit ' .. link_file_name) + feed('Abar<esc>') + command('write') + + local backup_raw = read_file(backup_file_name) + neq(nil, backup_raw, "Expected backup file " .. backup_file_name .. "to exist but did not") + eq(initial_content, trim(backup_raw), 'Expected backup to contain original contents') + end) + + + it('backup symlinked files in first avialable backupdir #11349', function() + if isCI('cirrus') then + pending('FIXME: cirrus') + end + clear() + + local initial_content = 'foo' + local backup_dir = 'Xtest_backupdir' + local sep = helpers.get_pathsep() + local link_file_name = 'Xtest_startup_file2' + local backup_file_name = backup_dir .. sep .. link_file_name .. '~' + + write_file('Xtest_startup_file1', initial_content, false) + lfs.link('Xtest_startup_file1', link_file_name, true) + mkdir(backup_dir) + command('set backup') + command('set backupcopy=yes') + command('set backupdir=.__this_does_not_exist__,' .. backup_dir) + command('edit ' .. link_file_name) + feed('Abar<esc>') + command('write') + + local backup_raw = read_file(backup_file_name) + neq(nil, backup_raw, "Expected backup file " .. backup_file_name .. " to exist but did not") + eq(initial_content, trim(backup_raw), 'Expected backup to contain original contents') + end) + it('readfile() on multibyte filename #10586', function() clear() local text = { |