annotate src/testdir/test_checkpath.vim @ 18478:94223687df0e

Added tag v8.1.2233 for changeset e93cab5d0f0f27fad7882f1f412927df055b090d
author Bram Moolenaar <Bram@vim.org>
date Tue, 29 Oct 2019 04:30:05 +0100
parents 6d9461653dc5
children 08940efa6b4e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16564
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for the :checkpath command
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 " Test for 'include' without \zs or \ze
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 func Test_checkpath1()
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 call mkdir("Xdir1/dir2", "p")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 call writefile(['#include "bar.a"'], 'Xdir1/dir2/foo.a')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 call writefile(['#include "baz.a"'], 'Xdir1/dir2/bar.a')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 call writefile(['#include "foo.a"'], 'Xdir1/dir2/baz.a')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 call writefile(['#include <foo.a>'], 'Xbase.a')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 edit Xbase.a
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 set path=Xdir1/dir2
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 let res = split(execute("checkpath!"), "\n")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 call assert_equal([
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 \ '--- Included files in path ---',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 \ 'Xdir1/dir2/foo.a',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 \ 'Xdir1/dir2/foo.a -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 \ ' Xdir1/dir2/bar.a',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 \ ' Xdir1/dir2/bar.a -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 \ ' Xdir1/dir2/baz.a',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 \ ' Xdir1/dir2/baz.a -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 \ ' "foo.a" (Already listed)'], res)
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 enew
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 call delete("./Xbase.a")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 call delete("Xdir1", "rf")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 set path&
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 endfunc
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 func DotsToSlashes()
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 return substitute(v:fname, '\.', '/', 'g') . '.b'
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 endfunc
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 " Test for 'include' with \zs and \ze
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 func Test_checkpath2()
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 call mkdir("Xdir1/dir2", "p")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 call writefile(['%inc /bar/'], 'Xdir1/dir2/foo.b')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 call writefile(['%inc /baz/'], 'Xdir1/dir2/bar.b')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 call writefile(['%inc /foo/'], 'Xdir1/dir2/baz.b')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 call writefile(['%inc /foo/'], 'Xbase.b')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 let &include='^\s*%inc\s*/\zs[^/]\+\ze'
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 let &includeexpr='DotsToSlashes()'
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 edit Xbase.b
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 set path=Xdir1/dir2
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 let res = split(execute("checkpath!"), "\n")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 call assert_equal([
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 \ '--- Included files in path ---',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 \ 'Xdir1/dir2/foo.b',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 \ 'Xdir1/dir2/foo.b -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 \ ' Xdir1/dir2/bar.b',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 \ ' Xdir1/dir2/bar.b -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 \ ' Xdir1/dir2/baz.b',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 \ ' Xdir1/dir2/baz.b -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 \ ' foo (Already listed)'], res)
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 enew
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 call delete("./Xbase.b")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 call delete("Xdir1", "rf")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 set path&
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 set include&
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 set includeexpr&
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 endfunc
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 func StripNewlineChar()
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 if v:fname =~ '\n$'
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 return v:fname[:-2]
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 endif
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 return v:fname
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 endfunc
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 " Test for 'include' with \zs and no \ze
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 func Test_checkpath3()
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 call mkdir("Xdir1/dir2", "p")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 call writefile(['%inc bar.c'], 'Xdir1/dir2/foo.c')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 call writefile(['%inc baz.c'], 'Xdir1/dir2/bar.c')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 call writefile(['%inc foo.c'], 'Xdir1/dir2/baz.c')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 call writefile(['%inc foo.c'], 'Xdir1/dir2/FALSE.c')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 call writefile(['%inc FALSE.c foo.c'], 'Xbase.c')
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 let &include='^\s*%inc\s*\%([[:upper:]][^[:space:]]*\s\+\)\?\zs\S\+\ze'
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 let &includeexpr='StripNewlineChar()'
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 edit Xbase.c
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 set path=Xdir1/dir2
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 let res = split(execute("checkpath!"), "\n")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 call assert_equal([
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 \ '--- Included files in path ---',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 \ 'Xdir1/dir2/foo.c',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 \ 'Xdir1/dir2/foo.c -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 \ ' Xdir1/dir2/bar.c',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 \ ' Xdir1/dir2/bar.c -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 \ ' Xdir1/dir2/baz.c',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 \ ' Xdir1/dir2/baz.c -->',
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 \ ' foo.c (Already listed)'], res)
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 enew
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 call delete("./Xbase.c")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 call delete("Xdir1", "rf")
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 set path&
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 set include&
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 set includeexpr&
6d9461653dc5 patch 8.1.1285: test17 is old style
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 endfunc