comparison src/testdir/test_writefile.vim @ 21580:93dae47699fb v8.2.1340

patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD Commit: https://github.com/vim/vim/commit/b86abadf87bd0f85f800077171ec4b98aefff776 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 1 16:08:19 2020 +0200 patch 8.2.1340: some tests fail on Cirrus CI and/or with FreeBSD Problem: Some tests fail on Cirrus CI and/or with FreeBSD. Solution: Make 'backupskip' empty. Do not run tests as root. Check for directory when using viminfo. (Ozaki Kiichi, closes #6596)
author Bram Moolenaar <Bram@vim.org>
date Sat, 01 Aug 2020 16:15:04 +0200
parents dc1c26547a42
children 08940efa6b4e
comparison
equal deleted inserted replaced
21579:30c6a9fb9e8d 21580:93dae47699fb
134 call writefile(['two'], 'Xtest', 'S') 134 call writefile(['two'], 'Xtest', 'S')
135 call delete('Xtest') 135 call delete('Xtest')
136 endfunc 136 endfunc
137 137
138 func Test_writefile_sync_dev_stdout() 138 func Test_writefile_sync_dev_stdout()
139 if !has('unix') 139 CheckUnix
140 return
141 endif
142 if filewritable('/dev/stdout') 140 if filewritable('/dev/stdout')
143 " Just check that this doesn't cause an error. 141 " Just check that this doesn't cause an error.
144 call writefile(['one'], '/dev/stdout') 142 call writefile(['one'], '/dev/stdout')
145 else 143 else
146 throw 'Skipped: /dev/stdout is not writable' 144 throw 'Skipped: /dev/stdout is not writable'
369 call delete('Xfile') 367 call delete('Xfile')
370 endfunc 368 endfunc
371 369
372 " Test for writing to a readonly file 370 " Test for writing to a readonly file
373 func Test_write_readonly() 371 func Test_write_readonly()
374 " In Cirrus-CI, the freebsd tests are run under a root account. So this test
375 " doesn't fail.
376 CheckNotBSD
377 call writefile([], 'Xfile') 372 call writefile([], 'Xfile')
378 call setfperm('Xfile', "r--------") 373 call setfperm('Xfile', "r--------")
379 edit Xfile 374 edit Xfile
380 set noreadonly 375 set noreadonly backupskip=
381 call assert_fails('write', 'E505:') 376 call assert_fails('write', 'E505:')
382 let save_cpo = &cpo 377 let save_cpo = &cpo
383 set cpo+=W 378 set cpo+=W
384 call assert_fails('write!', 'E504:') 379 call assert_fails('write!', 'E504:')
385 let &cpo = save_cpo 380 let &cpo = save_cpo
386 call setline(1, ['line1']) 381 call setline(1, ['line1'])
387 write! 382 write!
388 call assert_equal(['line1'], readfile('Xfile')) 383 call assert_equal(['line1'], readfile('Xfile'))
384 set backupskip&
389 call delete('Xfile') 385 call delete('Xfile')
390 endfunc 386 endfunc
391 387
392 " Test for 'patchmode' 388 " Test for 'patchmode'
393 func Test_patchmode() 389 func Test_patchmode()
394 CheckNotBSD
395 call writefile(['one'], 'Xfile') 390 call writefile(['one'], 'Xfile')
396 set patchmode=.orig nobackup writebackup 391 set patchmode=.orig nobackup backupskip= writebackup
397 new Xfile 392 new Xfile
398 call setline(1, 'two') 393 call setline(1, 'two')
399 " first write should create the .orig file 394 " first write should create the .orig file
400 write 395 write
401 " TODO: Xfile.orig is not created in Cirrus FreeBSD CI test
402 call assert_equal(['one'], readfile('Xfile.orig')) 396 call assert_equal(['one'], readfile('Xfile.orig'))
403 call setline(1, 'three') 397 call setline(1, 'three')
404 " subsequent writes should not create/modify the .orig file 398 " subsequent writes should not create/modify the .orig file
405 write 399 write
406 call assert_equal(['one'], readfile('Xfile.orig')) 400 call assert_equal(['one'], readfile('Xfile.orig'))
407 set patchmode& backup& writebackup& 401 set patchmode& backup& backupskip& writebackup&
408 call delete('Xfile') 402 call delete('Xfile')
409 call delete('Xfile.orig') 403 call delete('Xfile.orig')
410 endfunc 404 endfunc
411 405
412 " Test for writing to a file in a readonly directory 406 " Test for writing to a file in a readonly directory
413 func Test_write_readonly_dir() 407 func Test_write_readonly_dir()
414 if !has('unix') || has('bsd') 408 " On MS-Windows, modifying files in a read-only directory is allowed.
415 " On MS-Windows, modifying files in a read-only directory is allowed. 409 CheckUnix
416 " In Cirrus-CI for Freebsd, tests are run under a root account where
417 " modifying files in a read-only directory are allowed.
418 return
419 endif
420 call mkdir('Xdir') 410 call mkdir('Xdir')
421 call writefile(['one'], 'Xdir/Xfile1') 411 call writefile(['one'], 'Xdir/Xfile1')
422 call setfperm('Xdir', 'r-xr--r--') 412 call setfperm('Xdir', 'r-xr--r--')
423 " try to create a new file in the directory 413 " try to create a new file in the directory
424 new Xdir/Xfile2 414 new Xdir/Xfile2
425 call setline(1, 'two') 415 call setline(1, 'two')
426 call assert_fails('write', 'E212:') 416 call assert_fails('write', 'E212:')
427 " try to create a backup file in the directory 417 " try to create a backup file in the directory
428 edit! Xdir/Xfile1 418 edit! Xdir/Xfile1
429 set backupdir=./Xdir 419 set backupdir=./Xdir backupskip=
430 set patchmode=.orig 420 set patchmode=.orig
431 call assert_fails('write', 'E509:') 421 call assert_fails('write', 'E509:')
432 call setfperm('Xdir', 'rwxr--r--') 422 call setfperm('Xdir', 'rwxr--r--')
433 call delete('Xdir', 'rf') 423 call delete('Xdir', 'rf')
434 set backupdir& patchmode& 424 set backupdir& backupskip& patchmode&
435 endfunc 425 endfunc
436 426
437 " Test for writing a file using invalid file encoding 427 " Test for writing a file using invalid file encoding
438 func Test_write_invalid_encoding() 428 func Test_write_invalid_encoding()
439 new 429 new