annotate src/testdir/test_cscope.vim @ 9768:b31da25b19c4 v7.4.2159

commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 5 21:25:29 2016 +0200 patch 7.4.2159 Problem: Insufficient testing for cscope. Solution: Add more tests. (Dominique Pelle)
author Christian Brabandt <cb@256bit.org>
date Fri, 05 Aug 2016 21:30:05 +0200
parents ab96eb561a7e
children c470694733db
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')
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
43 call assert_fails('cscope add doesnotexist.out', 'E563')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
44 call assert_fails('cscope kill 2', 'E261')
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
45 " Test 1: Find this C-Symbol
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
46 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
47 " 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
48 call assert_equal('main(void)', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
49 " 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
50 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
51
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
52 " Test 2: Find this definition
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
53 cscope find g test_mf_hash
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
54 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
55
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
56 " 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
57 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
58 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
59 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
60
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
61 " 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
62 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
63 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
64 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
65
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
66 " Test 5: Find this text string
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
67 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
68 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
69 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
70
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
71 " Test 6: Find this egrep pattern
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
72 " test all matches returned by cscope
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
73 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
74 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
75 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
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 "main.c"', getline('.'))
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
78 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
79 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
80 call assert_fails('cnext', 'E553')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
81
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
82 " Test 7: Find this file
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
83 enew
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
84 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
85 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
86 call assert_equal('Xmemfile_test.c', @%)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
87
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
88 " 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
89 enew
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
90 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
91 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
92 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
93
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
94 " Test 9: Invalid find command
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
95 call assert_fails('cs find x', 'E560')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
96
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
97 " Test 10: Find places where this symbol is assigned a value
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
98 " this needs a cscope >= 15.8
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
99 " unfortunately, Travis has cscope version 15.7
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
100 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
101 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
102 if cs_version >= 15.8
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
103 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
104 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
105 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
106 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
107 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
108 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
109 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
110 cnext
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
111 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
112 endif
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
113
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
114 " Test 11: leading whitespace is not removed for cscope find text
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
115 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
116 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
117 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
118
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
119 " Test 12: cscope help
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
120 let a=execute('cscope help')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
121 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
122 call assert_match('\nadd :', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
123 call assert_match('\nfind :', a)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
124 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
125 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
126 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
127 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
128
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
129 " Test 13: reset connections
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
130 let a=execute('cscope reset')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
131 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
132 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
133
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
134 " Test 14: cscope show
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
135 let a=execute('cscope show')
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
136 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
137
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
138 " Test 15: cstag and 'csto' option
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
139 set csto=0
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
140 let a=execute('cstag TEST_COUNT')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
141 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
142 call assert_equal('#define TEST_COUNT 50000', getline('.'))
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
143 set csto=1
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
144 let a=execute('cstag index_to_key')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
145 call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a)
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
146 call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.'))
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
147 call assert_fails('cstag xxx', 'E257')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
148 call assert_fails('cstag', 'E562')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
149
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
150 " Test 15: 'csprg' option
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
151 call assert_equal('cscope', &csprg)
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
152
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
153 " Test 16: 'cst' option
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
154 set cst
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
155 let a=execute('tag TEST_COUNT')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
156 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
157 call assert_equal('#define TEST_COUNT 50000', getline('.'))
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
158 set nocst
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
159 call assert_fails('tag TEST_COUNT', 'E426')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
160
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
161 " CleanUp
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
162 call CscopeSetupOrClean(0)
9768
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
163
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
164 " cscope command should fail after killing scope connection.
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
165 call assert_fails('cscope find s main', 'E567')
b31da25b19c4 commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9
Christian Brabandt <cb@256bit.org>
parents: 9746
diff changeset
166
9746
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
167 endfunc
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
168
ab96eb561a7e commit https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34
Christian Brabandt <cb@256bit.org>
parents: 9505
diff changeset
169 " vim: shiftwidth=2 sts=2 expandtab