annotate src/testdir/test_cd.vim @ 34495:d43c2e4b645c v9.1.0154

patch 9.1.0154: shm=F not respected when reloading buffer with 'autoread' Commit: https://github.com/vim/vim/commit/9db39b0ec90600bb41faec3a12b934b17c298b1f Author: Shougo Matsushita <Shougo.Matsu@gmail.com> Date: Wed Mar 6 20:58:41 2024 +0100 patch 9.1.0154: shm=F not respected when reloading buffer with 'autoread' Problem: shm=F not respected when reloading buffer with 'autoread' Solution: Check SHM_FILEINFO in buf_check_timestamp() (Shougo Matsushita) closes: #14144 Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 06 Mar 2024 21:15:03 +0100
parents f7a2de8a4ddc
children a0f822031bfc
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
26809
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26412
diff changeset
47 " Test for :cd - after a failed :cd
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26412
diff changeset
48 call assert_fails('cd /nonexistent', 'E344:')
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26412
diff changeset
49 call assert_equal(path, getcwd())
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26412
diff changeset
50 cd -
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26412
diff changeset
51 call assert_equal(path_dotdot, getcwd())
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26412
diff changeset
52 cd -
1c22fcc7415c patch 8.2.3933: after ":cd" fails ":cd -" is incorrect
Bram Moolenaar <Bram@vim.org>
parents: 26412
diff changeset
53
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
54 " 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
55 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
56 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
57 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
58 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
59 qall!
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
60 [SCRIPT]
30164
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
61 call writefile(lines, 'Xscript', 'D')
19370
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
62 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
63 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
64 endif
02111977dd05 patch 8.2.0243: insufficient code coverage for ex_docmd.c functions
Bram Moolenaar <Bram@vim.org>
parents: 19261
diff changeset
65 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
66 endfunc
a1d21fc6e457 patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents: 11213
diff changeset
67
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
68 " Test for chdir()
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
69 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
70 let topdir = getcwd()
30164
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
71 call mkdir('Xchdir/y/z', 'pR')
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
72
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
73 " 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
74 new
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
75 cd Xchdir
16576
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
76 tabnew
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
77 tcd y
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
78 below new
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
79 below new
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
80 lcd z
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
81
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
82 tabfirst
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
83 call assert_match('^\[global\] .*/Xchdir$', 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
84 call chdir('..')
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('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
86 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
87 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
88 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
89 eval '..'->chdir()
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
90 call assert_equal('Xchdir', fnamemodify(getcwd(1, 2), ':t'))
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
91 call assert_equal('Xchdir', fnamemodify(getcwd(2, 2), ':t'))
16576
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('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
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 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
95 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
96 call chdir('..')
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
97 call assert_equal('Xchdir', fnamemodify(getcwd(1, 2), ':t'))
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
98 call assert_equal('Xchdir', fnamemodify(getcwd(2, 2), ':t'))
16576
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('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
100 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
101
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
102 " Error case
21265
6a4806e326dd patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents: 20848
diff changeset
103 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
104 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
105 call assert_equal("", d)
19261
a20c66f13a6e patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
106 " Should not crash
a20c66f13a6e patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents: 18977
diff changeset
107 call chdir(d)
20158
94f05de75e9f patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents: 19370
diff changeset
108 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
109
bcc343175103 patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents: 14256
diff changeset
110 only | tabonly
18568
26a04a556982 patch 8.1.2278: using "cd" with "exe" may fail
Bram Moolenaar <Bram@vim.org>
parents: 17857
diff changeset
111 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
112 endfunc
18977
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
113
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
114 " 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
115 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
116 let topdir = getcwd()
30164
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
117 call mkdir('Xprevdir/a/b/c', 'pR')
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
118
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
119 " 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
120 new | only
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
121 tabnew | new
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
122 tabnew
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
123 tabfirst
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
124 cd Xprevdir
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
125 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
126 tcd a
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
127 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
128 lcd b
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
129 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
130 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
131
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
132 " 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
133 tabfirst
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
134 cd - | cd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
135 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
136 tcd - | tcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
137 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
138 lcd - | lcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
139 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
140 tcd - | tcd -
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
141
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
142 " 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
143 tabfirst
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
144 call assert_equal('Xprevdir', fnamemodify(getcwd(), ':t'))
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
145 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
146 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
147 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
148 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
149 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
150 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
151
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
152 " 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
153 tabfirst
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 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
156 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
157 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
158 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
159 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
160 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
161
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
162 " 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
163 tabfirst
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 26809
diff changeset
164 call assert_equal('Xprevdir', fnamemodify(getcwd(), ':t'))
20711
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
165 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
166 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
167 wincmd w
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
168 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
169 tabnext
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
170 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
171
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
172 only | tabonly
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
173 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
174 endfunc
d91b8d1e5198 patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents: 20645
diff changeset
175
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
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184
25200
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
185 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
186 CheckNotMSWindows
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
187
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
188 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
189 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
190 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
191 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
192
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
193 " 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
194 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
195 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
196 cd -
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
197 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
198 endfunc
da0e5ff44b14 patch 8.2.3136: no test for E187 and "No swap file"
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
199
18977
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
200 func Test_cd_completion()
30164
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
201 call mkdir('XComplDir1', 'D')
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
202 call mkdir('XComplDir2', 'D')
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
203 call writefile([], 'XComplFile', 'D')
18977
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
204
5bef1043abff patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 18568
diff changeset
205 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
206 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
207 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
208 endfor
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
25868
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
211 func Test_cd_unknown_dir()
30164
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
212 call mkdir('Xa', 'R')
25868
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
213 cd Xa
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
214 call writefile(['text'], 'Xb.txt')
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
215 edit Xa/Xb.txt
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
216 let first_buf = bufnr()
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
217 cd ..
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
218 edit
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
219 call assert_equal(first_buf, bufnr())
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
220 edit Xa/Xb.txt
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
221 call assert_notequal(first_buf, bufnr())
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
222
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
223 bwipe!
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
224 exe "bwipe! " .. first_buf
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
225 endfunc
bcf55847d2ed patch 8.2.3468: problem with :cd when editing file in non-existent directory
Bram Moolenaar <Bram@vim.org>
parents: 25200
diff changeset
226
26173
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
227 func Test_getcwd_actual_dir()
26412
40f6330abc2c patch 8.2.3737: test fails without the 'autochdir' option
Bram Moolenaar <Bram@vim.org>
parents: 26173
diff changeset
228 CheckOption autochdir
40f6330abc2c patch 8.2.3737: test fails without the 'autochdir' option
Bram Moolenaar <Bram@vim.org>
parents: 26173
diff changeset
229
26173
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
230 let startdir = getcwd()
30164
f7a2de8a4ddc patch 9.0.0418: manually deleting temp test files
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
231 call mkdir('Xactual', 'R')
26173
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
232 call test_autochdir()
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
233 set autochdir
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
234 edit Xactual/file.txt
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
235 call assert_match('testdir.Xactual$', getcwd())
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
236 lcd ..
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
237 call assert_match('testdir$', getcwd())
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
238 edit
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
239 call assert_match('testdir.Xactual$', getcwd())
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
240 call assert_match('testdir$', getcwd(win_getid()))
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
241
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
242 set noautochdir
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
243 bwipe!
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
244 call chdir(startdir)
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
245 endfunc
460790b520dd patch 8.2.3618: getcwd() is unclear about how 'autochdir' is used
Bram Moolenaar <Bram@vim.org>
parents: 25868
diff changeset
246
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21723
diff changeset
247 " vim: shiftwidth=2 sts=2 expandtab