Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_backup.vim tests fail when built under /tmp #3301

Closed
jonathonf opened this issue Aug 8, 2018 · 5 comments
Closed

test_backup.vim tests fail when built under /tmp #3301

jonathonf opened this issue Aug 8, 2018 · 5 comments

Comments

@jonathonf
Copy link

jonathonf commented Aug 8, 2018

Edit: Issue title changed; real reason was due to documented behaviour of skipping backup files in temporary locations, see @chrisbra's reply below.

Summary

The tests in test_backup.vim as introduced in b782ba4#diff-56cbec7ca8be0936c91499a3c49255c7 fail when the filesystem is mounted with noatime.

Tests pass when the filesystem is mounted e.g. relatime.

(Not sure if this is the tests, the changes as introduced, or that it has never "worked" but it's now being tested.)

Test failure output

Executed 398 tests
3 FAILED:
Found errors in Test_backup():
Caught exception in Test_backup(): Vim(let):E484: Can't open file Xbackup.txt~ @ function RunTheTest[40]..Test_backup, line 9
Found errors in Test_backup2():
function RunTheTest[40]..Test_backup2 line 10: Expected ['line1', 'line2', 'line3'] but got ['']
function RunTheTest[40]..Test_backup2 line 12: Pattern '%testdir%Xbackup.txt\\~' does not match '*Xbackup.txt~'
Found errors in Test_backup2_backupcopy():
function RunTheTest[40]..Test_backup2_backupcopy line 10: Expected ['line1', 'line2', 'line3'] but got ['']
function RunTheTest[40]..Test_backup2_backupcopy line 12: Pattern '%testdir%Xbackup.txt\\~' does not match '*Xbackup.txt~'


From test_alot.vim:
Found errors in Test_backup():
Caught exception in Test_backup(): Vim(let):E484: Can't open file Xbackup.txt~ @ function RunTheTest[40]..Test_backup, line 9
Found errors in Test_backup2():
function RunTheTest[40]..Test_backup2 line 10: Expected ['line1', 'line2', 'line3'] but got ['']
function RunTheTest[40]..Test_backup2 line 12: Pattern '%testdir%Xbackup.txt\\~' does not match '*Xbackup.txt~'
Found errors in Test_backup2_backupcopy():
function RunTheTest[40]..Test_backup2_backupcopy line 10: Expected ['line1', 'line2', 'line3'] but got ['']
function RunTheTest[40]..Test_backup2_backupcopy line 12: Pattern '%testdir%Xbackup.txt\\~' does not match '*Xbackup.txt~'

Test results:


From test_alot.vim:
Found errors in Test_backup():
Caught exception in Test_backup(): Vim(let):E484: Can't open file Xbackup.txt~ @ function RunTheTest[40]..Test_backup, line 9
Found errors in Test_backup2():
function RunTheTest[40]..Test_backup2 line 10: Expected ['line1', 'line2', 'line3'] but got ['']
function RunTheTest[40]..Test_backup2 line 12: Pattern '%testdir%Xbackup.txt\\~' does not match '*Xbackup.txt~'
Found errors in Test_backup2_backupcopy():
function RunTheTest[40]..Test_backup2_backupcopy line 10: Expected ['line1', 'line2', 'line3'] but got ['']
function RunTheTest[40]..Test_backup2_backupcopy line 12: Pattern '%testdir%Xbackup.txt\\~' does not match '*Xbackup.txt~'
TEST FAILURE
@brammool
Copy link
Contributor

brammool commented Aug 9, 2018 via email

@chrisbra
Copy link
Member

chrisbra commented Aug 9, 2018

Perhaps somehow backupskip kicks in?

@jonathonf
Copy link
Author

Are you sure this is caused by "noatime" and not another difference?

You know, I spent two or three hours last night narrowing down the issue and I was pretty certain it was due to noatime. Then I try to replicate again this evening and I can't. 😡

So, these steps don't work to replicate:

$ sudo mount -t tmpfs -o noatime tmpfs /mnt
$ mount | grep /mnt
tmpfs on /mnt type tmpfs (rw,noatime)
... (build) ...
--> tests don't fail
$ sudo mount -o remount,relatime /mnt
$ mount | grep /mnt
tmpfs on /mnt type tmpfs (rw,relatime)
... (build) ...
--> tests pass

However, when I try to build in /tmp, which is set noatime via my /etc/fstab, the tests fail. If I remount that relatime, then tests ... still fail.

Wat.

So, it appears something here is being messed up by whatever is "special" about this particular tmpfs. This doesn't make a lot of sense to me; I'll do more digging.

(Just to confirm it's not running out of space:

$ df -h | grep tmp
devtmpfs                     16G     0   16G   0% /dev
tmpfs                        16G   17M   16G   1% /dev/shm
tmpfs                        16G  1.6M   16G   1% /run
tmpfs                        16G     0   16G   0% /sys/fs/cgroup
tmpfs                        16G  192K   16G   1% /tmp
tmpfs                       3.2G  121M  3.1G   4% /run/user/1000
tmpfs                        16G  192M   16G   2% /mnt

/mnt contains the successfully-built Vim.)

@chrisbra
Copy link
Member

chrisbra commented Aug 9, 2018

However, when I try to build in /tmp, which is set noatime via my /etc/fstab, the tests fail. If I remount that relatime, then tests ... still fail.

This is expected, because quoting the documentation:

When one of the patterns matches with the name of the file which is written, no backup file is created

I have run previously into this problem. Perhaps this patch is needed in addition:

diff --git a/src/testdir/test_backup.vim b/src/testdir/test_backup.vim
index 0981efdce..ce2bfe72b 100644
--- a/src/testdir/test_backup.vim
+++ b/src/testdir/test_backup.vim
@@ -1,7 +1,7 @@
 " Tests for the backup function

 func Test_backup()
-  set backup backupdir=.
+  set backup backupdir=. backupskip=
   new
   call setline(1, ['line1', 'line2'])
   :f Xbackup.txt
@@ -12,13 +12,13 @@ func Test_backup()
   let l = readfile('Xbackup.txt~')
   call assert_equal(['line1', 'line2'], l)
   bw!
-  set backup&vim backupdir&vim
+  set backup&vim backupdir&vim backupskip&vim
   call delete('Xbackup.txt')
   call delete('Xbackup.txt~')
 endfunc

 func Test_backup2()
-  set backup backupdir=.//
+  set backup backupdir=.// backupskip=
   new
   call setline(1, ['line1', 'line2', 'line3'])
   :f Xbackup.txt
@@ -34,11 +34,11 @@ func Test_backup2()
   bw!
   call delete('Xbackup.txt')
   call delete(f)
-  set backup&vim backupdir&vim
+  set backup&vim backupdir&vim backupskip&vim
 endfunc

 func Test_backup2_backupcopy()
-  set backup backupdir=.// backupcopy=yes
+  set backup backupdir=.// backupcopy=yes backupskip=
   new
   call setline(1, ['line1', 'line2', 'line3'])
   :f Xbackup.txt
@@ -54,5 +54,5 @@ func Test_backup2_backupcopy()
   bw!
   call delete('Xbackup.txt')
   call delete(f)
-  set backup&vim backupdir&vim backupcopy&vim
+  set backup&vim backupdir&vim backupcopy&vim backupskip&vim
 endfunc

@jonathonf
Copy link
Author

Yup, that got the tests passing.

I'll edit the issue title to fit the actual reason for the test failures.

@jonathonf jonathonf changed the title test_backup.vim tests fail when filesystem mounted noatime test_backup.vim tests fail when built under /tmp Aug 9, 2018
janlazo added a commit to janlazo/neovim that referenced this issue Aug 2, 2020
Problem:    Backup tests fail when CWD is in /tmp.
Solution:   Make 'backupskip' empty. (Christian Brabandt, closes vim/vim#3301)
vim/vim@efe0373
farisachugthai pushed a commit to farisachugthai/neovim that referenced this issue Aug 4, 2020
Problem:    Backup tests fail when CWD is in /tmp.
Solution:   Make 'backupskip' empty. (Christian Brabandt, closes vim/vim#3301)
vim/vim@efe0373
tjdevries pushed a commit to tjdevries/neovim that referenced this issue Aug 5, 2020
Problem:    Backup tests fail when CWD is in /tmp.
Solution:   Make 'backupskip' empty. (Christian Brabandt, closes vim/vim#3301)
vim/vim@efe0373
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants