comparison src/testdir/test_checkpath.vim @ 29970:d891115c0aea v9.0.0323

patch 9.0.0323: using common name in tests leads to flaky tests Commit: https://github.com/vim/vim/commit/3b0d70f4ff436cb144683dafd956e8a3ee485a90 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 29 22:31:20 2022 +0100 patch 9.0.0323: using common name in tests leads to flaky tests Problem: Using common name in tests leads to flaky tests. Solution: Rename files and directories to be more specific.
author Bram Moolenaar <Bram@vim.org>
date Mon, 29 Aug 2022 23:45:04 +0200
parents 595ea7f099cd
children f7a2de8a4ddc
comparison
equal deleted inserted replaced
29969:5f2d38cacd6c 29970:d891115c0aea
1 " Tests for the :checkpath command 1 " Tests for the :checkpath command
2 2
3 " Test for 'include' without \zs or \ze 3 " Test for 'include' without \zs or \ze
4 func Test_checkpath1() 4 func Test_checkpath1()
5 call mkdir("Xdir1/dir2", "p") 5 call mkdir("Xcheckdir1/dir2", "p")
6 call writefile(['#include "bar.a"'], 'Xdir1/dir2/foo.a') 6 call writefile(['#include "bar.a"'], 'Xcheckdir1/dir2/foo.a')
7 call writefile(['#include "baz.a"'], 'Xdir1/dir2/bar.a') 7 call writefile(['#include "baz.a"'], 'Xcheckdir1/dir2/bar.a')
8 call writefile(['#include "foo.a"'], 'Xdir1/dir2/baz.a') 8 call writefile(['#include "foo.a"'], 'Xcheckdir1/dir2/baz.a')
9 call writefile(['#include <foo.a>'], 'Xbase.a') 9 call writefile(['#include <foo.a>'], 'Xbase.a')
10 10
11 edit Xbase.a 11 edit Xbase.a
12 set path=Xdir1/dir2 12 set path=Xcheckdir1/dir2
13 let res = split(execute("checkpath!"), "\n") 13 let res = split(execute("checkpath!"), "\n")
14 call assert_equal([ 14 call assert_equal([
15 \ '--- Included files in path ---', 15 \ '--- Included files in path ---',
16 \ 'Xdir1/dir2/foo.a', 16 \ 'Xcheckdir1/dir2/foo.a',
17 \ 'Xdir1/dir2/foo.a -->', 17 \ 'Xcheckdir1/dir2/foo.a -->',
18 \ ' Xdir1/dir2/bar.a', 18 \ ' Xcheckdir1/dir2/bar.a',
19 \ ' Xdir1/dir2/bar.a -->', 19 \ ' Xcheckdir1/dir2/bar.a -->',
20 \ ' Xdir1/dir2/baz.a', 20 \ ' Xcheckdir1/dir2/baz.a',
21 \ ' Xdir1/dir2/baz.a -->', 21 \ ' Xcheckdir1/dir2/baz.a -->',
22 \ ' "foo.a" (Already listed)'], res) 22 \ ' "foo.a" (Already listed)'], res)
23 23
24 enew 24 enew
25 call delete("./Xbase.a") 25 call delete("./Xbase.a")
26 call delete("Xdir1", "rf") 26 call delete("Xcheckdir1", "rf")
27 set path& 27 set path&
28 endfunc 28 endfunc
29 29
30 func DotsToSlashes() 30 func DotsToSlashes()
31 return substitute(v:fname, '\.', '/', 'g') . '.b' 31 return substitute(v:fname, '\.', '/', 'g') . '.b'
32 endfunc 32 endfunc
33 33
34 " Test for 'include' with \zs and \ze 34 " Test for 'include' with \zs and \ze
35 func Test_checkpath2() 35 func Test_checkpath2()
36 call mkdir("Xdir1/dir2", "p") 36 call mkdir("Xcheckdir2/dir2", "p")
37 call writefile(['%inc /bar/'], 'Xdir1/dir2/foo.b') 37 call writefile(['%inc /bar/'], 'Xcheckdir2/dir2/foo.b')
38 call writefile(['%inc /baz/'], 'Xdir1/dir2/bar.b') 38 call writefile(['%inc /baz/'], 'Xcheckdir2/dir2/bar.b')
39 call writefile(['%inc /foo/'], 'Xdir1/dir2/baz.b') 39 call writefile(['%inc /foo/'], 'Xcheckdir2/dir2/baz.b')
40 call writefile(['%inc /foo/'], 'Xbase.b') 40 call writefile(['%inc /foo/'], 'Xbase.b')
41 41
42 let &include='^\s*%inc\s*/\zs[^/]\+\ze' 42 let &include='^\s*%inc\s*/\zs[^/]\+\ze'
43 let &includeexpr='DotsToSlashes()' 43 let &includeexpr='DotsToSlashes()'
44 44
45 edit Xbase.b 45 edit Xbase.b
46 set path=Xdir1/dir2 46 set path=Xcheckdir2/dir2
47 let res = split(execute("checkpath!"), "\n") 47 let res = split(execute("checkpath!"), "\n")
48 call assert_equal([ 48 call assert_equal([
49 \ '--- Included files in path ---', 49 \ '--- Included files in path ---',
50 \ 'Xdir1/dir2/foo.b', 50 \ 'Xcheckdir2/dir2/foo.b',
51 \ 'Xdir1/dir2/foo.b -->', 51 \ 'Xcheckdir2/dir2/foo.b -->',
52 \ ' Xdir1/dir2/bar.b', 52 \ ' Xcheckdir2/dir2/bar.b',
53 \ ' Xdir1/dir2/bar.b -->', 53 \ ' Xcheckdir2/dir2/bar.b -->',
54 \ ' Xdir1/dir2/baz.b', 54 \ ' Xcheckdir2/dir2/baz.b',
55 \ ' Xdir1/dir2/baz.b -->', 55 \ ' Xcheckdir2/dir2/baz.b -->',
56 \ ' foo (Already listed)'], res) 56 \ ' foo (Already listed)'], res)
57 57
58 enew 58 enew
59 call delete("./Xbase.b") 59 call delete("./Xbase.b")
60 call delete("Xdir1", "rf") 60 call delete("Xcheckdir2", "rf")
61 set path& 61 set path&
62 set include& 62 set include&
63 set includeexpr& 63 set includeexpr&
64 endfunc 64 endfunc
65 65
70 return v:fname 70 return v:fname
71 endfunc 71 endfunc
72 72
73 " Test for 'include' with \zs and no \ze 73 " Test for 'include' with \zs and no \ze
74 func Test_checkpath3() 74 func Test_checkpath3()
75 call mkdir("Xdir1/dir2", "p") 75 call mkdir("Xcheckdir3/dir2", "p")
76 call writefile(['%inc bar.c'], 'Xdir1/dir2/foo.c') 76 call writefile(['%inc bar.c'], 'Xcheckdir3/dir2/foo.c')
77 call writefile(['%inc baz.c'], 'Xdir1/dir2/bar.c') 77 call writefile(['%inc baz.c'], 'Xcheckdir3/dir2/bar.c')
78 call writefile(['%inc foo.c'], 'Xdir1/dir2/baz.c') 78 call writefile(['%inc foo.c'], 'Xcheckdir3/dir2/baz.c')
79 call writefile(['%inc foo.c'], 'Xdir1/dir2/FALSE.c') 79 call writefile(['%inc foo.c'], 'Xcheckdir3/dir2/FALSE.c')
80 call writefile(['%inc FALSE.c foo.c'], 'Xbase.c') 80 call writefile(['%inc FALSE.c foo.c'], 'Xbase.c')
81 81
82 let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze' 82 let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
83 let &includeexpr='StripNewlineChar()' 83 let &includeexpr='StripNewlineChar()'
84 84
85 edit Xbase.c 85 edit Xbase.c
86 set path=Xdir1/dir2 86 set path=Xcheckdir3/dir2
87 let res = split(execute("checkpath!"), "\n") 87 let res = split(execute("checkpath!"), "\n")
88 call assert_equal([ 88 call assert_equal([
89 \ '--- Included files in path ---', 89 \ '--- Included files in path ---',
90 \ 'Xdir1/dir2/foo.c', 90 \ 'Xcheckdir3/dir2/foo.c',
91 \ 'Xdir1/dir2/foo.c -->', 91 \ 'Xcheckdir3/dir2/foo.c -->',
92 \ ' Xdir1/dir2/bar.c', 92 \ ' Xcheckdir3/dir2/bar.c',
93 \ ' Xdir1/dir2/bar.c -->', 93 \ ' Xcheckdir3/dir2/bar.c -->',
94 \ ' Xdir1/dir2/baz.c', 94 \ ' Xcheckdir3/dir2/baz.c',
95 \ ' Xdir1/dir2/baz.c -->', 95 \ ' Xcheckdir3/dir2/baz.c -->',
96 \ ' foo.c (Already listed)'], res) 96 \ ' foo.c (Already listed)'], res)
97 97
98 enew 98 enew
99 call delete("./Xbase.c") 99 call delete("./Xbase.c")
100 call delete("Xdir1", "rf") 100 call delete("Xcheckdir3", "rf")
101 set path& 101 set path&
102 set include& 102 set include&
103 set includeexpr& 103 set includeexpr&
104 endfunc 104 endfunc
105 105