annotate src/testdir/test_cd.vim @ 20848:d3fa0d29fa9a v8.2.0976

patch 8.2.0976: some 'cpoptions' not tested Commit: https://github.com/vim/vim/commit/df7df59d85e7e56a796912dc865488a75d3f0e53 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 14 13:50:55 2020 +0200 patch 8.2.0976: some 'cpoptions' not tested Problem: Some 'cpoptions' not tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/6253)
author Bram Moolenaar <Bram@vim.org>
date Sun, 14 Jun 2020 14:00:03 +0200
parents d91b8d1e5198
children 6a4806e326dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
1 " Test for :cd and chdir()
11213
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
3 source shared.vim
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
4
11213
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 func Test_cd_large_path()
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " This used to crash with a heap write overflow.
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 call assert_fails('cd ' . repeat('x', 5000), 'E472:')
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 endfunc
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 func Test_cd_up_and_down()
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 let path = getcwd()
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 cd ..
14256
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
13 call assert_notequal(path, getcwd())
18568
26a04a556982 patch 8.1.2278: using "cd" with "exe" may fail
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
14 exe 'cd ' .. fnameescape(path)
11213
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call assert_equal(path, getcwd())
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 endfunc
14256
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
17
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
18 func Test_cd_no_arg()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
19 if has('unix')
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
20 " Test that cd without argument goes to $HOME directory on Unix systems.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
21 let path = getcwd()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
22 cd
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
23 call assert_equal($HOME, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
24 call assert_notequal(path, getcwd())
18568
26a04a556982 patch 8.1.2278: using "cd" with "exe" may fail
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
25 exe 'cd ' .. fnameescape(path)
14256
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
26 call assert_equal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
27 else
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
28 " Test that cd without argument echoes cwd on non-Unix systems.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
29 call assert_match(getcwd(), execute('cd'))
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
30 endif
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
31 endfunc
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
32
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
33 func Test_cd_minus()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
34 " Test the :cd - goes back to the previous directory.
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
35 let path = getcwd()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
36 cd ..
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
37 let path_dotdot = getcwd()
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
38 call assert_notequal(path, path_dotdot)
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
39 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
40 call assert_equal(path, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
41 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
42 call assert_equal(path_dotdot, getcwd())
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
43 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
44 call assert_equal(path, getcwd())
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
45
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
46 " Test for :cd - without a previous directory
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
47 let lines =<< trim [SCRIPT]
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
48 call assert_fails('cd -', 'E186:')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
49 call assert_fails('call chdir("-")', 'E186:')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
50 call writefile(v:errors, 'Xresult')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
51 qall!
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
52 [SCRIPT]
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
53 call writefile(lines, 'Xscript')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
54 if RunVim([], [], '--clean -S Xscript')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
55 call assert_equal([], readfile('Xresult'))
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
56 endif
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
57 call delete('Xscript')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
58 call delete('Xresult')
14256
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
59 endfunc
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
60
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
61 " Test for chdir()
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
62 func Test_chdir_func()
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
63 let topdir = getcwd()
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
64 call mkdir('Xdir/y/z', 'p')
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
65
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
66 " Create a few tabpages and windows with different directories
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
67 new
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
68 cd Xdir
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
69 tabnew
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
70 tcd y
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
71 below new
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
72 below new
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
73 lcd z
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
74
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
75 tabfirst
20645
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
76 call assert_match('^\[global\] .*/Xdir$', trim(execute('verbose pwd')))
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
77 call chdir('..')
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
78 call assert_equal('y', fnamemodify(getcwd(1, 2), ':t'))
17857
4935244c1128 patch 8.1.1925: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 17837
diff changeset
79 call assert_equal('z', fnamemodify(3->getcwd(2), ':t'))
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
80 tabnext | wincmd t
20645
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
81 call assert_match('^\[tabpage\] .*/y$', trim(execute('verbose pwd')))
17837
f71ee7b04f0b patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents: 16576
diff changeset
82 eval '..'->chdir()
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
83 call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
84 call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t'))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
85 call assert_equal('z', fnamemodify(getcwd(3, 2), ':t'))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
86 call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
87 3wincmd w
20645
b60bb094af52 patch 8.2.0876: :pwd does not give a hint about the scope of the directory
Bram Moolenaar <Bram@vim.org>
parents: 20158
diff changeset
88 call assert_match('^\[window\] .*/z$', trim(execute('verbose pwd')))
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
89 call chdir('..')
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
90 call assert_equal('Xdir', fnamemodify(getcwd(1, 2), ':t'))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
91 call assert_equal('Xdir', fnamemodify(getcwd(2, 2), ':t'))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
92 call assert_equal('y', fnamemodify(getcwd(3, 2), ':t'))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
93 call assert_equal('testdir', fnamemodify(getcwd(1, 1), ':t'))
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
94
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
95 " Error case
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
96 call assert_fails("call chdir('dir-abcd')", 'E472:')
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
97 silent! let d = chdir("dir_abcd")
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
98 call assert_equal("", d)
19261
a20c66f13a6e patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
99 " Should not crash
a20c66f13a6e patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
100 call chdir(d)
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
101 call assert_equal('', chdir([]))
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
102
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
103 only | tabonly
18568
26a04a556982 patch 8.1.2278: using "cd" with "exe" may fail
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
104 call chdir(topdir)
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
105 call delete('Xdir', 'rf')
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
106 endfunc
18977
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
107
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
108 " Test for changing to the previous directory '-'
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
109 func Test_prev_dir()
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
110 let topdir = getcwd()
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
111 call mkdir('Xdir/a/b/c', 'p')
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
112
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
113 " Create a few tabpages and windows with different directories
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
114 new | only
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
115 tabnew | new
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
116 tabnew
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
117 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
118 cd Xdir
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
119 tabnext | wincmd t
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
120 tcd a
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
121 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
122 lcd b
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
123 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
124 tcd a/b/c
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
125
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
126 " Change to the previous directory twice in all the windows.
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
127 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
128 cd - | cd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
129 tabnext | wincmd t
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
130 tcd - | tcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
131 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
132 lcd - | lcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
133 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
134 tcd - | tcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
135
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
136 " Check the directory of all the windows
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
137 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
138 call assert_equal('Xdir', fnamemodify(getcwd(), ':t'))
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
139 tabnext | wincmd t
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
140 call assert_equal('a', fnamemodify(getcwd(), ':t'))
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
141 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
142 call assert_equal('b', fnamemodify(getcwd(), ':t'))
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
143 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
144 call assert_equal('c', fnamemodify(getcwd(), ':t'))
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
145
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
146 " Change to the previous directory using chdir()
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
147 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
148 call chdir("-") | call chdir("-")
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
149 tabnext | wincmd t
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
150 call chdir("-") | call chdir("-")
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
151 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
152 call chdir("-") | call chdir("-")
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
153 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
154 call chdir("-") | call chdir("-")
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
155
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
156 " Check the directory of all the windows
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
157 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
158 call assert_equal('Xdir', fnamemodify(getcwd(), ':t'))
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
159 tabnext | wincmd t
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
160 call assert_equal('a', fnamemodify(getcwd(), ':t'))
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
161 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
162 call assert_equal('b', fnamemodify(getcwd(), ':t'))
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
163 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
164 call assert_equal('c', fnamemodify(getcwd(), ':t'))
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
165
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
166 only | tabonly
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
167 call chdir(topdir)
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
168 call delete('Xdir', 'rf')
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
169 endfunc
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
170
18977
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
171 func Test_cd_completion()
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
172 call mkdir('XComplDir1', 'p')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
173 call mkdir('XComplDir2', 'p')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
174 call writefile([], 'XComplFile')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
175
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
176 for cmd in ['cd', 'chdir', 'lcd', 'lchdir', 'tcd', 'tchdir']
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
177 call feedkeys(':' .. cmd .. " XCompl\<C-A>\<C-B>\"\<CR>", 'tx')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
178 call assert_equal('"' .. cmd .. ' XComplDir1/ XComplDir2/', @:)
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
179 endfor
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
180
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
181 call delete('XComplDir1', 'd')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
182 call delete('XComplDir2', 'd')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
183 call delete('XComplFile')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
184 endfunc