Mercurial > vim
annotate src/testdir/test_cd.vim @ 20776:7728e309e013 v8.2.0940
patch 8.2.0940: build failure with tiny features
Commit: https://github.com/vim/vim/commit/0ca8b5ba7ba72d739ee15d0d6534aa20f863f3c3
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 9 21:35:36 2020 +0200
patch 8.2.0940: build failure with tiny features
Problem: Build failure with tiny features.
Solution: Add #ifdef. Add UNUSED. A bit more cleaning up.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 09 Jun 2020 21:45:03 +0200 |
parents | d91b8d1e5198 |
children | d3fa0d29fa9a |
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 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
61 func Test_cd_with_cpo_chdir() |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
62 e Xfoo |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
63 call setline(1, 'foo') |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
64 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
|
65 set cpo+=. |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
66 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
67 " :cd should fail when buffer is modified and 'cpo' contains dot. |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
68 call assert_fails('cd ..', 'E747:') |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
69 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
|
70 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
71 " :cd with exclamation mark should succeed. |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
72 cd! .. |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
73 call assert_notequal(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
|
74 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
75 " :cd should succeed when buffer has been written. |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
76 w! |
18568
26a04a556982
patch 8.1.2278: using "cd" with "exe" may fail
Bram Moolenaar <Bram@vim.org>
parents:
17857
diff
changeset
|
77 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
|
78 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
|
79 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
80 call delete('Xfoo') |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
81 set cpo& |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
82 bw! |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
83 endfunc |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
84 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
85 " Test for chdir() |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
86 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
|
87 let topdir = getcwd() |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
88 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
|
89 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
90 " 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
|
91 new |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
92 cd Xdir |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
93 tabnew |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
94 tcd y |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
95 below new |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
96 below new |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
97 lcd z |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
98 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
99 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
|
100 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
|
101 call chdir('..') |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
102 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
|
103 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
|
104 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
|
105 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
|
106 eval '..'->chdir() |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 call chdir('..') |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 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
|
118 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
119 " Error case |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
120 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
|
121 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
|
122 call assert_equal("", d) |
19261
a20c66f13a6e
patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents:
18977
diff
changeset
|
123 " Should not crash |
a20c66f13a6e
patch 8.2.0189: cd() with NULL argument crashes
Bram Moolenaar <Bram@vim.org>
parents:
18977
diff
changeset
|
124 call chdir(d) |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
19370
diff
changeset
|
125 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
|
126 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
127 only | tabonly |
18568
26a04a556982
patch 8.1.2278: using "cd" with "exe" may fail
Bram Moolenaar <Bram@vim.org>
parents:
17857
diff
changeset
|
128 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
|
129 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
|
130 endfunc |
18977
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
131 |
20711
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
132 " 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
|
133 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
|
134 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
|
135 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
|
136 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
137 " 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
|
138 new | only |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
139 tabnew | new |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
140 tabnew |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
141 tabfirst |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
142 cd Xdir |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
143 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
|
144 tcd a |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
145 wincmd w |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
146 lcd b |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
147 tabnext |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
148 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
|
149 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
150 " 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
|
151 tabfirst |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
152 cd - | cd - |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
153 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
|
154 tcd - | tcd - |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
155 wincmd w |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
156 lcd - | lcd - |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
157 tabnext |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
158 tcd - | tcd - |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
159 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
160 " 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
|
161 tabfirst |
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('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
|
163 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
|
164 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
|
165 wincmd w |
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('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
|
167 tabnext |
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('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
|
169 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
170 " 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
|
171 tabfirst |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
172 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
|
173 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
|
174 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
|
175 wincmd w |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
176 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
|
177 tabnext |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
178 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
|
179 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
180 " 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
|
181 tabfirst |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
182 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
|
183 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
|
184 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
|
185 wincmd w |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
186 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
|
187 tabnext |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
188 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
|
189 |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
190 only | tabonly |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
191 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
|
192 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
|
193 endfunc |
d91b8d1e5198
patch 8.2.0909: cannot go back to the previous local directory
Bram Moolenaar <Bram@vim.org>
parents:
20645
diff
changeset
|
194 |
18977
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
195 func Test_cd_completion() |
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
196 call mkdir('XComplDir1', 'p') |
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
197 call mkdir('XComplDir2', 'p') |
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
198 call writefile([], 'XComplFile') |
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
199 |
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
200 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
|
201 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
|
202 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
|
203 endfor |
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 call delete('XComplDir1', 'd') |
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
206 call delete('XComplDir2', 'd') |
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
207 call delete('XComplFile') |
5bef1043abff
patch 8.2.0049: command line completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
18568
diff
changeset
|
208 endfunc |