Mercurial > vim
annotate src/testdir/test_cd.vim @ 17950:bb0e25a8b5d7 v8.1.1971
patch 8.1.1971: manually enabling features causes build errors
Commit: https://github.com/vim/vim/commit/d570ab95d9ab0616f7d7cff59302617e612eae41
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 3 23:20:05 2019 +0200
patch 8.1.1971: manually enabling features causes build errors
Problem: Manually enabling features causes build errors. (John Marriott)
Solution: Adjust #ifdefs.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 03 Sep 2019 23:30:04 +0200 |
parents | 4935244c1128 |
children | 26a04a556982 |
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 |
290f5f6a2bac
patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 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
|
4 " 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
|
5 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
|
6 endfunc |
290f5f6a2bac
patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
290f5f6a2bac
patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 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
|
9 let path = getcwd() |
290f5f6a2bac
patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 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
|
11 call assert_notequal(path, getcwd()) |
11213
290f5f6a2bac
patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 exe 'cd ' . path |
290f5f6a2bac
patch 8.0.0493: crash with cd command with very long argument
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 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
|
14 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
|
15 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
16 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
|
17 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
|
18 " 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
|
19 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
|
20 cd |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
21 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
|
22 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
|
23 exe 'cd ' . path |
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(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
|
25 else |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
26 " 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
|
27 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
|
28 endif |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
29 endfunc |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
30 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
31 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
|
32 " 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
|
33 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
|
34 cd .. |
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_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
|
36 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
|
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 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
|
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_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
|
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, 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 endfunc |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
44 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
45 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
|
46 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
|
47 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
|
48 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
|
49 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
|
50 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
51 " :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
|
52 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
|
53 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
|
54 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
55 " :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
|
56 cd! .. |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
57 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
|
58 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
59 " :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
|
60 w! |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
61 exe 'cd ' . path |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
62 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
|
63 |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
64 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
|
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 bw! |
a1d21fc6e457
patch 8.1.0144: the :cd command does not have good test coverage
Christian Brabandt <cb@256bit.org>
parents:
11213
diff
changeset
|
67 endfunc |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
68 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
69 " Test for chdir() |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
70 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
|
71 let topdir = getcwd() |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
72 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
|
73 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
74 " 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
|
75 new |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
76 cd Xdir |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
77 tabnew |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
78 tcd y |
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 below new |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
81 lcd z |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
82 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
83 tabfirst |
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 |
17837
f71ee7b04f0b
patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
16576
diff
changeset
|
88 eval '..'->chdir() |
16576
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
89 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
|
90 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
|
91 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
|
92 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
|
93 3wincmd w |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
94 call chdir('..') |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
95 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
|
96 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
|
97 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
|
98 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
|
99 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
100 " Error case |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
101 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
|
102 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
|
103 call assert_equal("", d) |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
104 |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
105 only | tabonly |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
106 exe 'cd ' . topdir |
bcc343175103
patch 8.1.1291: not easy to change directory and restore
Bram Moolenaar <Bram@vim.org>
parents:
14256
diff
changeset
|
107 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
|
108 endfunc |