annotate src/testdir/test_cd.vim @ 25200:da0e5ff44b14 v8.2.3136

patch 8.2.3136: no test for E187 and "No swap file" Commit: https://github.com/vim/vim/commit/fe3418abe0dac65e42e85b5a91c5d0c975bc65bb Author: Dominique Pelle <dominique.pelle@gmail.com> Date: Sat Jul 10 17:59:48 2021 +0200 patch 8.2.3136: no test for E187 and "No swap file" Problem: No test for E187 and "No swap file". Solution: Add a test. (Dominique Pell?, closes https://github.com/vim/vim/issues/8540)
author Bram Moolenaar <Bram@vim.org>
date Sat, 10 Jul 2021 18:00:04 +0200
parents 08940efa6b4e
children bcf55847d2ed
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
25200
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
4 source check.vim
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
5
11213
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 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
7 " This used to crash with a heap write overflow.
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20848
diff changeset
8 call assert_fails('cd ' . repeat('x', 5000), 'E344:')
11213
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endfunc
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 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
12 let path = getcwd()
290f5f6a2bac patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 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
14 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
15 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
16 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
17 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
18
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
19 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
20 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
21 " 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
22 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
23 cd
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_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
25 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
26 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
27 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
28 else
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
29 " 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
30 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
31 endif
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
32 endfunc
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
33
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
34 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
35 " 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
36 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
37 cd ..
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
38 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
39 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
40 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
41 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
42 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
43 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
44 cd -
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
45 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
46
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
47 " 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
48 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
49 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
50 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
51 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
52 qall!
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
53 [SCRIPT]
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
54 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
55 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
56 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
57 endif
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('Xscript')
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
59 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
60 endfunc
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
61
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
62 " Test for chdir()
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
63 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
64 let topdir = getcwd()
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
65 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
66
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
67 " 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
68 new
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
69 cd Xdir
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
70 tabnew
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
71 tcd y
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 below new
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
74 lcd z
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
75
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
76 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
77 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
78 call chdir('..')
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
79 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
80 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
81 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
82 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
83 eval '..'->chdir()
16576
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(1, 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('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
86 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
87 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
88 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
89 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
90 call chdir('..')
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(1, 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('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
93 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
94 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
95
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
96 " Error case
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20848
diff changeset
97 call assert_fails("call chdir('dir-abcd')", 'E344:')
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
98 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
99 call assert_equal("", d)
19261
a20c66f13a6e patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
100 " Should not crash
a20c66f13a6e patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
101 call chdir(d)
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
102 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
103
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
104 only | tabonly
18568
26a04a556982 patch 8.1.2278: using "cd" with "exe" may fail
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
105 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
106 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
107 endfunc
18977
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
108
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
109 " 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
110 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
111 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
112 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
113
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
114 " 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
115 new | only
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
116 tabnew | new
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
117 tabnew
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
118 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
119 cd Xdir
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
120 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
121 tcd a
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
122 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
123 lcd b
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
124 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
125 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
126
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
127 " 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
128 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
129 cd - | cd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
130 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
131 tcd - | tcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
132 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
133 lcd - | lcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
134 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
135 tcd - | tcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
136
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
137 " 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
138 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
139 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
140 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
141 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
142 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
143 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
144 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
145 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
146
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
147 " 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
148 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
149 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
150 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
151 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
152 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
153 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
154 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
155 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
156
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
157 " 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
158 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
159 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
160 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
161 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
162 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
163 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
164 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
165 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
166
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
167 only | tabonly
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
168 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
169 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
170 endfunc
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
171
21723
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
172 func Test_lcd_split()
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
173 let curdir = getcwd()
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
174 lcd ..
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
175 split
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
176 lcd -
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
177 call assert_equal(curdir, getcwd())
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
178 quit!
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
179 endfunc
5b0796787cb2 patch 8.2.1411: when splitting a window localdir is copied but prevdir is not
Bram Moolenaar <Bram@vim.org>
parents: 21265
diff changeset
180
25200
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
181 func Test_cd_from_non_existing_dir()
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
182 CheckNotMSWindows
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
183
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
184 let saveddir = getcwd()
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
185 call mkdir('Xdeleted_dir')
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
186 cd Xdeleted_dir
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
187 call delete(saveddir .. '/Xdeleted_dir', 'd')
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
188
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
189 " Expect E187 as the current directory was deleted.
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
190 call assert_fails('pwd', 'E187:')
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
191 call assert_equal('', getcwd())
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
192 cd -
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
193 call assert_equal(saveddir, getcwd())
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
194 endfunc
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
195
18977
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
196 func Test_cd_completion()
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
197 call mkdir('XComplDir1', 'p')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
198 call mkdir('XComplDir2', 'p')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
199 call writefile([], 'XComplFile')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
200
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
201 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
202 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
203 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
204 endfor
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
205
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
206 call delete('XComplDir1', 'd')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
207 call delete('XComplDir2', 'd')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
208 call delete('XComplFile')
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
209 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21723
diff changeset
210
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21723
diff changeset
211 " vim: shiftwidth=2 sts=2 expandtab