annotate src/testdir/test_cscope.vim @ 9746:ab96eb561a7e v7.4.2148

commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 2 23:01:40 2016 +0200 patch 7.4.2148 Problem: Not much testing for cscope. Solution: Add a test that uses the cscope program. (Christian Brabandt)
author Christian Brabandt <cb@256bit.org>
date Tue, 02 Aug 2016 23:15:06 +0200
parents da98db362fef
children b31da25b19c4
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
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 func Test_cscopequickfix()
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 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
9 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
10
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 call assert_fails('set cscopequickfix=x-', 'E474:')
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 call assert_fails('set cscopequickfix=s', 'E474:')
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call assert_fails('set cscopequickfix=s7', 'E474:')
da98db362fef commit https://github.com/vim/vim/commit/6d20e1754461b0f8d395f2e3464f0dc1060497f7
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 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
15 endfunc
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
16
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
17 func CscopeSetupOrClean(setup)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
18 if a:setup
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
19 noa sp ../memfile_test.c
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
20 saveas! Xmemfile_test.c
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
21 call system('cscope -bk -fXcscope.out Xmemfile_test.c')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
22 cscope add Xcscope.out
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
23 set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-,a-
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
24 else
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
25 cscope kill -1
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
26 for file in ['Xcscope.out', 'Xmemfile_test.c']
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
27 call delete(file)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
28 endfor
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
29 endif
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
30 endfunc
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
31
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
32 func Test_cscope1()
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
33 call CscopeSetupOrClean(1)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
34 " Test 0: E568: duplicate cscope database not added
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
35 try
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
36 set nocscopeverbose
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
37 cscope add Xcscope.out
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
38 set cscopeverbose
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
39 catch
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
40 call assert_true(0)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
41 endtry
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
42 call assert_fails('cscope add Xcscope.out', 'E568')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
43 " Test 1: Find this C-Symbol
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
44 let a=execute('cscope find s main')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
45 " Test 1.1 test where it moves the cursor
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
46 call assert_equal('main(void)', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
47 " Test 1.2 test the output of the :cs command
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
48 call assert_match('\n(1 of 1): <<main>> main(void )', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
49
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
50 " Test 2: Find this definition
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
51 cscope find g test_mf_hash
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
52 call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', ' static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
53
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
54 " Test 3: Find functions called by this function
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
55 let a=execute('cscope find d test_mf_hash')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
56 call assert_match('\n(1 of 42): <<mf_hash_init>> mf_hash_init(&ht);', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
57 call assert_equal(' mf_hash_init(&ht);', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
58
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
59 " Test 4: Find functions calling this function
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
60 let a=execute('cscope find c test_mf_hash')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
61 call assert_match('\n(1 of 1): <<main>> test_mf_hash();', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
62 call assert_equal(' test_mf_hash();', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
63
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
64 " Test 5: Find this text string
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
65 let a=execute('cscope find t Bram')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
66 call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
67 call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
68
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
69 " Test 6: Find this egrep pattern
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
70 " test all matches returned by cscope
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
71 let a=execute('cscope find e ^\#includ.')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
72 call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
73 call assert_equal('#include <assert.h>', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
74 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
75 call assert_equal('#include "main.c"', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
76 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
77 call assert_equal('#include "memfile.c"', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
78 call assert_fails('cnext', 'E553')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
79
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
80 " Test 7: Find this file
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
81 enew
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
82 let a=execute('cscope find f Xmemfile_test.c')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
83 call assert_match('\n"Xmemfile_test.c" 143L, 3137C', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
84 call assert_equal('Xmemfile_test.c', @%)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
85
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
86 " Test 8: Find files #including this file
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
87 enew
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
88 let a=execute('cscope find i assert.h')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
89 call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <<global>> #include <assert.h>'], split(a, '\n', 1))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
90 call assert_equal('#include <assert.h>', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
91
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
92 " Test 9: Find places where this symbol is assigned a value
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
93 " this needs a cscope >= 15.8
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
94 " unfortunatly, Travis has cscope version 15.7
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
95 let cscope_version=systemlist('cscope --version')[0]
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
96 let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
97 if cs_version >= 15.8
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
98 let a=execute('cscope find a item')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
99 call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
100 call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
101 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
102 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
103 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
104 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
105 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
106 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
107 endif
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
108
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
109 " Test 10: leading whitespace is not removed for cscope find text
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
110 let a=execute('cscope find t test_mf_hash')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
111 call assert_equal(['', '(1 of 1): <<<unknown>>> test_mf_hash();'], split(a, '\n', 1))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
112 call assert_equal(' test_mf_hash();', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
113
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
114 " Test 11: cscope help
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
115 let a=execute('cscope help')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
116 call assert_match('^cscope commands:\n', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
117 call assert_match('\nadd :', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
118 call assert_match('\nfind :', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
119 call assert_match('\nhelp : Show this message', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
120 call assert_match('\nkill : Kill a connection', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
121 call assert_match('\nreset: Reinit all connections', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
122 call assert_match('\nshow : Show connections', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
123
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
124 " Test 12: reset connections
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
125 let a=execute('cscope reset')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
126 call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
127 call assert_match('\nAll cscope databases reset', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
128
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
129 " Test 13: cscope show
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
130 let a=execute('cscope show')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
131 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
132
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
133 " Test 14: 'csprg' option
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
134 call assert_equal('cscope', &csprg)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
135
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
136 " CleanUp
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
137 call CscopeSetupOrClean(0)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
138 endfunc
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
139
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
140 " vim: shiftwidth=2 sts=2 expandtab