annotate src/testdir/test_cscope.vim @ 11824:b276c1e73c27 v8.0.0792

patch 8.0.0792: spell test leaves files behind commit https://github.com/vim/vim/commit/1a0f2005002a9993ba7313d1978fa2043314f8b8 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 28 15:38:10 2017 +0200 patch 8.0.0792: spell test leaves files behind Problem: Spell test leaves files behind. Solution: Delete the files.
author Christian Brabandt <cb@256bit.org>
date Fri, 28 Jul 2017 15:45:04 +0200
parents 1c4ebbae41d2
children 741b1feeac9f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9505
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test for cscope commands.
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
3 if !has('cscope') || !executable('cscope') || !has('quickfix')
9505
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 finish
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 endif
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
9800
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
7 func CscopeSetupOrClean(setup)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
8 if a:setup
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
9 noa sp ../memfile_test.c
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
10 saveas! Xmemfile_test.c
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
11 call system('cscope -bk -fXcscope.out Xmemfile_test.c')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
12 call system('cscope -bk -fXcscope2.out Xmemfile_test.c')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
13 cscope add Xcscope.out
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
14 set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-,a-
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
15 else
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
16 cscope kill -1
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
17 for file in ['Xcscope.out', 'Xcscope2.out', 'Xmemfile_test.c']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
18 call delete(file)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
19 endfo
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
20 endif
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
21 endfunc
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
22
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
23 func Test_cscopeWithCscopeConnections()
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
24 call CscopeSetupOrClean(1)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
25 " Test 0: E568: duplicate cscope database not added
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
26 try
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
27 set nocscopeverbose
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
28 cscope add Xcscope.out
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
29 set cscopeverbose
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
30 catch
11183
1c4ebbae41d2 patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents: 10046
diff changeset
31 call assert_report('exception thrown')
9800
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
32 endtry
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
33 call assert_fails('cscope add', 'E560')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
34 call assert_fails('cscope add Xcscope.out', 'E568')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
35 call assert_fails('cscope add doesnotexist.out', 'E563')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
36
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
37 " Test 1: Find this C-Symbol
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
38 for cmd in ['cs find s main', 'cs find 0 main']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
39 let a=execute(cmd)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
40 " Test 1.1 test where it moves the cursor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
41 call assert_equal('main(void)', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
42 " Test 1.2 test the output of the :cs command
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
43 call assert_match('\n(1 of 1): <<main>> main(void )', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
44 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
45
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
46 " Test 2: Find this definition
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
47 for cmd in ['cs find g test_mf_hash', 'cs find 1 test_mf_hash']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
48 exe cmd
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
49 call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', ' static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
50 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
51
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
52 " Test 3: Find functions called by this function
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
53 for cmd in ['cs find d test_mf_hash', 'cs find 2 test_mf_hash']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
54 let a=execute(cmd)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
55 call assert_match('\n(1 of 42): <<mf_hash_init>> mf_hash_init(&ht);', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
56 call assert_equal(' mf_hash_init(&ht);', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
57 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
58
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
59 " Test 4: Find functions calling this function
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
60 for cmd in ['cs find c test_mf_hash', 'cs find 3 test_mf_hash']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
61 let a=execute(cmd)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
62 call assert_match('\n(1 of 1): <<main>> test_mf_hash();', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
63 call assert_equal(' test_mf_hash();', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
64 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
65
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
66 " Test 5: Find this text string
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
67 for cmd in ['cs find t Bram', 'cs find 4 Bram']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
68 let a=execute(cmd)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
69 call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
70 call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
71 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
72
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
73 " Test 6: Find this egrep pattern
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
74 " test all matches returned by cscope
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
75 for cmd in ['cs find e ^\#includ.', 'cs find 6 ^\#includ.']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
76 let a=execute(cmd)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
77 call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
78 call assert_equal('#include <assert.h>', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
79 cnext
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
80 call assert_equal('#include "main.c"', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
81 cnext
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
82 call assert_equal('#include "memfile.c"', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
83 call assert_fails('cnext', 'E553:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
84 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
85
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
86 " Test 7: Find the same egrep pattern using lcscope this time.
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
87 let a=execute('lcs find e ^\#includ.')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
88 call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
89 call assert_equal('#include <assert.h>', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
90 lnext
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
91 call assert_equal('#include "main.c"', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
92 lnext
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
93 call assert_equal('#include "memfile.c"', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
94 call assert_fails('lnext', 'E553:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
95
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
96 " Test 8: Find this file
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
97 for cmd in ['cs find f Xmemfile_test.c', 'cs find 7 Xmemfile_test.c']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
98 enew
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
99 let a=execute(cmd)
10046
4a07f8de5efa commit https://github.com/vim/vim/commit/4792255eff03760dca0fd014616532e6d47db364
Christian Brabandt <cb@256bit.org>
parents: 9800
diff changeset
100 call assert_true(a =~ '"Xmemfile_test.c" \d\+L, \d\+C')
9800
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
101 call assert_equal('Xmemfile_test.c', @%)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
102 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
103
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
104 " Test 9: Find files #including this file
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
105 for cmd in ['cs find i assert.h', 'cs find 8 assert.h']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
106 enew
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
107 let a=execute(cmd)
10046
4a07f8de5efa commit https://github.com/vim/vim/commit/4792255eff03760dca0fd014616532e6d47db364
Christian Brabandt <cb@256bit.org>
parents: 9800
diff changeset
108 let alines = split(a, '\n', 1)
4a07f8de5efa commit https://github.com/vim/vim/commit/4792255eff03760dca0fd014616532e6d47db364
Christian Brabandt <cb@256bit.org>
parents: 9800
diff changeset
109 call assert_equal('', alines[0])
4a07f8de5efa commit https://github.com/vim/vim/commit/4792255eff03760dca0fd014616532e6d47db364
Christian Brabandt <cb@256bit.org>
parents: 9800
diff changeset
110 call assert_true(alines[1] =~ '"Xmemfile_test.c" \d\+L, \d\+C')
4a07f8de5efa commit https://github.com/vim/vim/commit/4792255eff03760dca0fd014616532e6d47db364
Christian Brabandt <cb@256bit.org>
parents: 9800
diff changeset
111 call assert_equal('(1 of 1): <<global>> #include <assert.h>', alines[2])
9800
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
112 call assert_equal('#include <assert.h>', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
113 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
114
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
115 " Test 10: Invalid find command
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
116 call assert_fails('cs find x', 'E560:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
117
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
118 " Test 11: Find places where this symbol is assigned a value
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
119 " this needs a cscope >= 15.8
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
120 " unfortunately, Travis has cscope version 15.7
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
121 let cscope_version=systemlist('cscope --version')[0]
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
122 let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
123 if cs_version >= 15.8
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
124 for cmd in ['cs find a item', 'cs find 9 item']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
125 let a=execute(cmd)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
126 call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
127 call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
128 cnext
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
129 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
130 cnext
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
131 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
132 cnext
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
133 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
134 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
135 endif
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
136
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
137 " Test 12: leading whitespace is not removed for cscope find text
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
138 let a=execute('cscope find t test_mf_hash')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
139 call assert_equal(['', '(1 of 1): <<<unknown>>> test_mf_hash();'], split(a, '\n', 1))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
140 call assert_equal(' test_mf_hash();', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
141
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
142 " Test 13: test with scscope
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
143 let a=execute('scs find t Bram')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
144 call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
145 call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
146
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
147 " Test 14: cscope help
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
148 for cmd in ['cs', 'cs help', 'cs xxx']
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
149 let a=execute(cmd)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
150 call assert_match('^cscope commands:\n', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
151 call assert_match('\nadd :', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
152 call assert_match('\nfind :', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
153 call assert_match('\nhelp : Show this message', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
154 call assert_match('\nkill : Kill a connection', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
155 call assert_match('\nreset: Reinit all connections', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
156 call assert_match('\nshow : Show connections', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
157 endfor
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
158 let a=execute('scscope help')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
159 call assert_match('This cscope command does not support splitting the window\.', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
160
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
161 " Test 15: reset connections
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
162 let a=execute('cscope reset')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
163 call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
164 call assert_match('\nAll cscope databases reset', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
165
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
166 " Test 16: cscope show
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
167 let a=execute('cscope show')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
168 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
169
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
170 " Test 17: cstag and 'csto' option
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
171 set csto=0
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
172 let a=execute('cstag TEST_COUNT')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
173 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
174 call assert_equal('#define TEST_COUNT 50000', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
175 set csto=1
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
176 let a=execute('cstag index_to_key')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
177 call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
178 call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
179 call assert_fails('cstag xxx', 'E257:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
180 call assert_fails('cstag', 'E562:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
181
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
182 " Test 18: 'cst' option
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
183 set nocst
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
184 call assert_fails('tag TEST_COUNT', 'E426:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
185 set cst
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
186 let a=execute('tag TEST_COUNT')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
187 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
188 call assert_equal('#define TEST_COUNT 50000', getline('.'))
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
189 let a=execute('tags')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
190 call assert_match('1 1 TEST_COUNT\s\+\d\+\s\+#define index_to_key', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
191
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
192 " Test 19: this should trigger call to cs_print_tags()
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
193 " Unclear how to check result though, we just exercise the code.
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
194 set cst cscopequickfix=s0
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
195 call feedkeys(":cs find s main\<CR>", 't')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
196
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
197 " Test 20: cscope kill
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
198 call assert_fails('cscope kill 2', 'E261:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
199 call assert_fails('cscope kill xxx', 'E261:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
200
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
201 let a=execute('cscope kill 0')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
202 call assert_match('cscope connection 0 closed', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
203
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
204 cscope add Xcscope.out
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
205 let a=execute('cscope kill Xcscope.out')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
206 call assert_match('cscope connection Xcscope.out closed', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
207
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
208 cscope add Xcscope.out .
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
209 let a=execute('cscope kill -1')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
210 call assert_match('cscope connection .*Xcscope.out closed', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
211 let a=execute('cscope kill -1')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
212 call assert_equal('', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
213
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
214 " Test 21: 'csprg' option
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
215 call assert_equal('cscope', &csprg)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
216 set csprg=doesnotexist
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
217 call assert_fails('cscope add Xcscope2.out', 'E609:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
218 set csprg=cscope
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
219
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
220 " Test 22: multiple cscope connections
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
221 cscope add Xcscope.out
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
222 cscope add Xcscope2.out . -C
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
223 let a=execute('cscope show')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
224 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
225 call assert_match('\n 1 \d\+.*Xcscope2.out\s*\.', a)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
226
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
227 " Test 23: test Ex command line completion
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
228 call feedkeys(":cs \<C-A>\<C-B>\"\<CR>", 'tx')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
229 call assert_equal('"cs add find help kill reset show', @:)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
230
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
231 call feedkeys(":scs \<C-A>\<C-B>\"\<CR>", 'tx')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
232 call assert_equal('"scs find', @:)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
233
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
234 call feedkeys(":cs find \<C-A>\<C-B>\"\<CR>", 'tx')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
235 call assert_equal('"cs find a c d e f g i s t', @:)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
236
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
237 call feedkeys(":cs kill \<C-A>\<C-B>\"\<CR>", 'tx')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
238 call assert_equal('"cs kill -1 0 1', @:)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
239
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
240 call feedkeys(":cs add Xcscope\<C-A>\<C-B>\"\<CR>", 'tx')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
241 call assert_equal('"cs add Xcscope.out Xcscope2.out', @:)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
242
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
243 " Test 24: cscope_connection()
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
244 call assert_equal(cscope_connection(), 1)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
245 call assert_equal(cscope_connection(0, 'out'), 1)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
246 call assert_equal(cscope_connection(0, 'xxx'), 1)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
247 call assert_equal(cscope_connection(1, 'out'), 1)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
248 call assert_equal(cscope_connection(1, 'xxx'), 0)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
249 call assert_equal(cscope_connection(2, 'out'), 0)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
250 call assert_equal(cscope_connection(3, 'xxx', '..'), 0)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
251 call assert_equal(cscope_connection(3, 'out', 'xxx'), 0)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
252 call assert_equal(cscope_connection(3, 'out', '.'), 1)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
253 call assert_equal(cscope_connection(4, 'out', '.'), 0)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
254
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
255 " CleanUp
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
256 call CscopeSetupOrClean(0)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
257
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
258 endfunc
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
259
9505
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 func Test_cscopequickfix()
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 set cscopequickfix=s-,g-,d+,c-,t+,e-,f0,i-,a-
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262 call assert_equal('s-,g-,d+,c-,t+,e-,f0,i-,a-', &cscopequickfix)
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 call assert_fails('set cscopequickfix=x-', 'E474:')
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 call assert_fails('set cscopequickfix=s', 'E474:')
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 call assert_fails('set cscopequickfix=s7', 'E474:')
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 call assert_fails('set cscopequickfix=s-a', 'E474:')
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 endfunc
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
269
9800
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
270 func Test_withoutCscopeConnection()
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
271 call assert_equal(cscope_connection(), 0)
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
272
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
273 call assert_fails('cscope find s main', 'E567:')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
274 let a=execute('cscope show')
c470694733db commit https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4
Christian Brabandt <cb@256bit.org>
parents: 9768
diff changeset
275 call assert_match('no cscope connections', a)
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
276 endfunc
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
277
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
278
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
279 " vim: shiftwidth=2 sts=2 expandtab