Mercurial > vim
comparison src/testdir/test_swap.vim @ 12779:73eb8a2d7f04 v8.0.1267
patch 8.0.1267: Test_swap_group may leave file behind
commit https://github.com/vim/vim/commit/5842a748be8039fd6d267f5557fe391c6c95399d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 4 22:36:53 2017 +0100
patch 8.0.1267: Test_swap_group may leave file behind
Problem: Test_swap_group may leave file behind.
Solution: Add a try/finally.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 04 Nov 2017 22:45:06 +0100 |
parents | 3272e1cde1eb |
children | 4d5a1ada407e |
comparison
equal
deleted
inserted
replaced
12778:77a183c386a5 | 12779:73eb8a2d7f04 |
---|---|
54 let groups = split(system('groups')) | 54 let groups = split(system('groups')) |
55 if len(groups) <= 1 | 55 if len(groups) <= 1 |
56 throw 'Skipped: need at least two groups, got ' . string(groups) | 56 throw 'Skipped: need at least two groups, got ' . string(groups) |
57 endif | 57 endif |
58 | 58 |
59 call delete('Xtest') | 59 try |
60 split Xtest | 60 call delete('Xtest') |
61 call setline(1, 'just some text') | 61 split Xtest |
62 wq | 62 call setline(1, 'just some text') |
63 if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d' | 63 wq |
64 throw 'Skipped: test file does not have the first group' | 64 if system('ls -l Xtest') !~ ' ' . groups[0] . ' \d' |
65 else | 65 throw 'Skipped: test file does not have the first group' |
66 silent !chmod 640 Xtest | |
67 call system('chgrp ' . groups[1] . ' Xtest') | |
68 if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d' | |
69 throw 'Skipped: cannot set second group on test file' | |
70 else | 66 else |
71 split Xtest | 67 silent !chmod 640 Xtest |
72 let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g') | 68 call system('chgrp ' . groups[1] . ' Xtest') |
73 call assert_match('Xtest', swapname) | 69 if system('ls -l Xtest') !~ ' ' . groups[1] . ' \d' |
74 " Group of swapfile must now match original file. | 70 throw 'Skipped: cannot set second group on test file' |
75 call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname)) | 71 else |
72 split Xtest | |
73 let swapname = substitute(execute('swapname'), '[[:space:]]', '', 'g') | |
74 call assert_match('Xtest', swapname) | |
75 " Group of swapfile must now match original file. | |
76 call assert_match(' ' . groups[1] . ' \d', system('ls -l ' . swapname)) | |
76 | 77 |
77 bwipe! | 78 bwipe! |
79 endif | |
78 endif | 80 endif |
79 endif | 81 finally |
80 | 82 call delete('Xtest') |
81 call delete('Xtest') | 83 endtry |
82 endfunc | 84 endfunc |