From 845fa57db8430ac3e662096469fa328491905996 Mon Sep 17 00:00:00 2001 From: rover Date: Thu, 5 Jan 2017 22:17:58 +0800 Subject: vim-patch:7.4.2148 Problem: Not much testing for cscope. Solution: Add a test that uses the cscope program. (Christian Brabandt) https://github.com/vim/vim/commit/edf634e0f1985c5ea1afb5b480b47a44cabbce34 --- src/nvim/testdir/test_cscope.vim | 127 ++++++++++++++++++++++++++++++++++++++- src/nvim/version.c | 2 +- 2 files changed, 127 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_cscope.vim b/src/nvim/testdir/test_cscope.vim index b6d70f0765..0beeb058bb 100644 --- a/src/nvim/testdir/test_cscope.vim +++ b/src/nvim/testdir/test_cscope.vim @@ -1,6 +1,6 @@ " Test for cscope commands. -if !has('cscope') +if !has('cscope') || !executable('cscope') || !has('quickfix') finish endif @@ -13,3 +13,128 @@ func Test_cscopequickfix() call assert_fails('set cscopequickfix=s7', 'E474:') call assert_fails('set cscopequickfix=s-a', 'E474:') endfunc + +func CscopeSetupOrClean(setup) + if a:setup + noa sp ../memfile_test.c + saveas! Xmemfile_test.c + call system('cscope -bk -fXcscope.out Xmemfile_test.c') + cscope add Xcscope.out + set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-,a- + else + cscope kill -1 + for file in ['Xcscope.out', 'Xmemfile_test.c'] + call delete(file) + endfor + endif +endfunc + +func Test_cscope1() + call CscopeSetupOrClean(1) + " Test 0: E568: duplicate cscope database not added + try + set nocscopeverbose + cscope add Xcscope.out + set cscopeverbose + catch + call assert_true(0) + endtry + call assert_fails('cscope add Xcscope.out', 'E568') + " Test 1: Find this C-Symbol + let a=execute('cscope find s main') + " Test 1.1 test where it moves the cursor + call assert_equal('main(void)', getline('.')) + " Test 1.2 test the output of the :cs command + call assert_match('\n(1 of 1): <
> main(void )', a) + + " Test 2: Find this definition + cscope find g test_mf_hash + call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', ' static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1)) + + " Test 3: Find functions called by this function + let a=execute('cscope find d test_mf_hash') + call assert_match('\n(1 of 42): <> mf_hash_init(&ht);', a) + call assert_equal(' mf_hash_init(&ht);', getline('.')) + + " Test 4: Find functions calling this function + let a=execute('cscope find c test_mf_hash') + call assert_match('\n(1 of 1): <
> test_mf_hash();', a) + call assert_equal(' test_mf_hash();', getline('.')) + + " Test 5: Find this text string + let a=execute('cscope find t Bram') + call assert_match('(1 of 1): <<>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a) + call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.')) + + " Test 6: Find this egrep pattern + " test all matches returned by cscope + let a=execute('cscope find e ^\#includ.') + call assert_match('\n(1 of 3): <<>> #include ', a) + call assert_equal('#include ', getline('.')) + cnext + call assert_equal('#include "main.c"', getline('.')) + cnext + call assert_equal('#include "memfile.c"', getline('.')) + call assert_fails('cnext', 'E553') + + " Test 7: Find this file + enew + let a=execute('cscope find f Xmemfile_test.c') + call assert_match('\n"Xmemfile_test.c" 143L, 3137C', a) + call assert_equal('Xmemfile_test.c', @%) + + " Test 8: Find files #including this file + enew + let a=execute('cscope find i assert.h') + call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <> #include '], split(a, '\n', 1)) + call assert_equal('#include ', getline('.')) + + " Test 9: Find places where this symbol is assigned a value + " this needs a cscope >= 15.8 + " unfortunatly, Travis has cscope version 15.7 + let cscope_version=systemlist('cscope --version')[0] + let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) + if cs_version >= 15.8 + let a=execute('cscope find a item') + call assert_equal(['', '(1 of 4): <> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1)) + call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + endif + + " Test 10: leading whitespace is not removed for cscope find text + let a=execute('cscope find t test_mf_hash') + call assert_equal(['', '(1 of 1): <<>> test_mf_hash();'], split(a, '\n', 1)) + call assert_equal(' test_mf_hash();', getline('.')) + + " Test 11: cscope help + let a=execute('cscope help') + call assert_match('^cscope commands:\n', a) + call assert_match('\nadd :', a) + call assert_match('\nfind :', a) + call assert_match('\nhelp : Show this message', a) + call assert_match('\nkill : Kill a connection', a) + call assert_match('\nreset: Reinit all connections', a) + call assert_match('\nshow : Show connections', a) + + " Test 12: reset connections + let a=execute('cscope reset') + call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a) + call assert_match('\nAll cscope databases reset', a) + + " Test 13: cscope show + let a=execute('cscope show') + call assert_match('\n 0 \d\+.*Xcscope.out\s*', a) + + " Test 14: 'csprg' option + call assert_equal('cscope', &csprg) + + " CleanUp + call CscopeSetupOrClean(0) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index 73b5c96be0..f34421aae0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -292,7 +292,7 @@ static int included_patches[] = { // 2151, // 2150 NA 2149, - // 2148, + 2148, 2147, 2146, // 2145 NA -- cgit From a5dd1274628cb88ee538469594c0b75ab9a59e7e Mon Sep 17 00:00:00 2001 From: rover Date: Sat, 7 Jan 2017 19:52:37 +0800 Subject: vim-patch:7.4.2159 Problem: Insufficient testing for cscope. Solution: Add more tests. (Dominique Pelle) https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9 --- src/nvim/testdir/test_cscope.vim | 43 +++++++++++++++++++++++++++++++++------- src/nvim/version.c | 2 +- 2 files changed, 37 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_cscope.vim b/src/nvim/testdir/test_cscope.vim index 0beeb058bb..2c7ed9fcce 100644 --- a/src/nvim/testdir/test_cscope.vim +++ b/src/nvim/testdir/test_cscope.vim @@ -40,6 +40,8 @@ func Test_cscope1() call assert_true(0) endtry call assert_fails('cscope add Xcscope.out', 'E568') + call assert_fails('cscope add doesnotexist.out', 'E563') + call assert_fails('cscope kill 2', 'E261') " Test 1: Find this C-Symbol let a=execute('cscope find s main') " Test 1.1 test where it moves the cursor @@ -89,9 +91,12 @@ func Test_cscope1() call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <> #include '], split(a, '\n', 1)) call assert_equal('#include ', getline('.')) - " Test 9: Find places where this symbol is assigned a value + " Test 9: Invalid find command + call assert_fails('cs find x', 'E560') + + " Test 10: Find places where this symbol is assigned a value " this needs a cscope >= 15.8 - " unfortunatly, Travis has cscope version 15.7 + " unfortunately, Travis has cscope version 15.7 let cscope_version=systemlist('cscope --version')[0] let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) if cs_version >= 15.8 @@ -106,12 +111,12 @@ func Test_cscope1() call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) endif - " Test 10: leading whitespace is not removed for cscope find text + " Test 11: leading whitespace is not removed for cscope find text let a=execute('cscope find t test_mf_hash') call assert_equal(['', '(1 of 1): <<>> test_mf_hash();'], split(a, '\n', 1)) call assert_equal(' test_mf_hash();', getline('.')) - " Test 11: cscope help + " Test 12: cscope help let a=execute('cscope help') call assert_match('^cscope commands:\n', a) call assert_match('\nadd :', a) @@ -121,20 +126,44 @@ func Test_cscope1() call assert_match('\nreset: Reinit all connections', a) call assert_match('\nshow : Show connections', a) - " Test 12: reset connections + " Test 13: reset connections let a=execute('cscope reset') call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a) call assert_match('\nAll cscope databases reset', a) - " Test 13: cscope show + " Test 14: cscope show let a=execute('cscope show') call assert_match('\n 0 \d\+.*Xcscope.out\s*', a) - " Test 14: 'csprg' option + " Test 15: cstag and 'csto' option + set csto=0 + let a=execute('cstag TEST_COUNT') + call assert_match('(1 of 1): <> #define TEST_COUNT 50000', a) + call assert_equal('#define TEST_COUNT 50000', getline('.')) + set csto=1 + let a=execute('cstag index_to_key') + call assert_match('(1 of 1): <> #define index_to_key(i) ((i) ^ 15167)', a) + call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.')) + call assert_fails('cstag xxx', 'E257') + call assert_fails('cstag', 'E562') + + " Test 15: 'csprg' option call assert_equal('cscope', &csprg) + " Test 16: 'cst' option + set cst + let a=execute('tag TEST_COUNT') + call assert_match('(1 of 1): <> #define TEST_COUNT 50000', a) + call assert_equal('#define TEST_COUNT 50000', getline('.')) + set nocst + call assert_fails('tag TEST_COUNT', 'E426') + " CleanUp call CscopeSetupOrClean(0) + + " cscope command should fail after killing scope connection. + call assert_fails('cscope find s main', 'E567') + endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index f34421aae0..73bdfc3116 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -281,7 +281,7 @@ static int included_patches[] = { 2162, // 2161, 2160, - // 2159, + 2159, 2158, // 2157 NA // 2156 NA -- cgit From 40a306fe901132de2fbaf772c14727e24c68512d Mon Sep 17 00:00:00 2001 From: rover Date: Sat, 7 Jan 2017 19:58:57 +0800 Subject: vim-patch:7.4.2175 Problem: Insufficient testing of cscope. Solution: Add more tests. (Dominique Pelle) https://github.com/vim/vim/commit/812ad4f3a2cb33002a24f6b5862c7b375cd68fe4 --- src/nvim/testdir/test_cscope.vim | 271 +++++++++++++++++++++++++++------------ src/nvim/version.c | 2 +- 2 files changed, 190 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_cscope.vim b/src/nvim/testdir/test_cscope.vim index 2c7ed9fcce..e9ed490372 100644 --- a/src/nvim/testdir/test_cscope.vim +++ b/src/nvim/testdir/test_cscope.vim @@ -4,32 +4,23 @@ if !has('cscope') || !executable('cscope') || !has('quickfix') finish endif -func Test_cscopequickfix() - set cscopequickfix=s-,g-,d+,c-,t+,e-,f0,i-,a- - call assert_equal('s-,g-,d+,c-,t+,e-,f0,i-,a-', &cscopequickfix) - - call assert_fails('set cscopequickfix=x-', 'E474:') - call assert_fails('set cscopequickfix=s', 'E474:') - call assert_fails('set cscopequickfix=s7', 'E474:') - call assert_fails('set cscopequickfix=s-a', 'E474:') -endfunc - func CscopeSetupOrClean(setup) if a:setup noa sp ../memfile_test.c saveas! Xmemfile_test.c call system('cscope -bk -fXcscope.out Xmemfile_test.c') + call system('cscope -bk -fXcscope2.out Xmemfile_test.c') cscope add Xcscope.out set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-,a- else cscope kill -1 - for file in ['Xcscope.out', 'Xmemfile_test.c'] + for file in ['Xcscope.out', 'Xcscope2.out', 'Xmemfile_test.c'] call delete(file) - endfor + endfo endif endfunc -func Test_cscope1() +func Test_cscopeWithCscopeConnections() call CscopeSetupOrClean(1) " Test 0: E568: duplicate cscope database not added try @@ -39,103 +30,141 @@ func Test_cscope1() catch call assert_true(0) endtry + call assert_fails('cscope add', 'E560') call assert_fails('cscope add Xcscope.out', 'E568') call assert_fails('cscope add doesnotexist.out', 'E563') - call assert_fails('cscope kill 2', 'E261') + " Test 1: Find this C-Symbol - let a=execute('cscope find s main') - " Test 1.1 test where it moves the cursor - call assert_equal('main(void)', getline('.')) - " Test 1.2 test the output of the :cs command - call assert_match('\n(1 of 1): <
> main(void )', a) + for cmd in ['cs find s main', 'cs find 0 main'] + let a=execute(cmd) + " Test 1.1 test where it moves the cursor + call assert_equal('main(void)', getline('.')) + " Test 1.2 test the output of the :cs command + call assert_match('\n(1 of 1): <
> main(void )', a) + endfor " Test 2: Find this definition - cscope find g test_mf_hash - call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', ' static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1)) + for cmd in ['cs find g test_mf_hash', 'cs find 1 test_mf_hash'] + exe cmd + call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', ' static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1)) + endfor " Test 3: Find functions called by this function - let a=execute('cscope find d test_mf_hash') - call assert_match('\n(1 of 42): <> mf_hash_init(&ht);', a) - call assert_equal(' mf_hash_init(&ht);', getline('.')) + for cmd in ['cs find d test_mf_hash', 'cs find 2 test_mf_hash'] + let a=execute(cmd) + call assert_match('\n(1 of 42): <> mf_hash_init(&ht);', a) + call assert_equal(' mf_hash_init(&ht);', getline('.')) + endfor " Test 4: Find functions calling this function - let a=execute('cscope find c test_mf_hash') - call assert_match('\n(1 of 1): <
> test_mf_hash();', a) - call assert_equal(' test_mf_hash();', getline('.')) + for cmd in ['cs find c test_mf_hash', 'cs find 3 test_mf_hash'] + let a=execute(cmd) + call assert_match('\n(1 of 1): <
> test_mf_hash();', a) + call assert_equal(' test_mf_hash();', getline('.')) + endfor " Test 5: Find this text string - let a=execute('cscope find t Bram') - call assert_match('(1 of 1): <<>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a) - call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.')) + for cmd in ['cs find t Bram', 'cs find 4 Bram'] + let a=execute(cmd) + call assert_match('(1 of 1): <<>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a) + call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.')) + endfor " Test 6: Find this egrep pattern " test all matches returned by cscope - let a=execute('cscope find e ^\#includ.') + for cmd in ['cs find e ^\#includ.', 'cs find 6 ^\#includ.'] + let a=execute(cmd) + call assert_match('\n(1 of 3): <<>> #include ', a) + call assert_equal('#include ', getline('.')) + cnext + call assert_equal('#include "main.c"', getline('.')) + cnext + call assert_equal('#include "memfile.c"', getline('.')) + call assert_fails('cnext', 'E553:') + endfor + + " Test 7: Find the same egrep pattern using lcscope this time. + let a=execute('lcs find e ^\#includ.') call assert_match('\n(1 of 3): <<>> #include ', a) call assert_equal('#include ', getline('.')) - cnext + lnext call assert_equal('#include "main.c"', getline('.')) - cnext + lnext call assert_equal('#include "memfile.c"', getline('.')) - call assert_fails('cnext', 'E553') - - " Test 7: Find this file - enew - let a=execute('cscope find f Xmemfile_test.c') - call assert_match('\n"Xmemfile_test.c" 143L, 3137C', a) - call assert_equal('Xmemfile_test.c', @%) - - " Test 8: Find files #including this file - enew - let a=execute('cscope find i assert.h') - call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <> #include '], split(a, '\n', 1)) - call assert_equal('#include ', getline('.')) + call assert_fails('lnext', 'E553:') + + " Test 8: Find this file + for cmd in ['cs find f Xmemfile_test.c', 'cs find 7 Xmemfile_test.c'] + enew + let a=execute(cmd) + call assert_match('\n"Xmemfile_test.c" 143L, 3137C', a) + call assert_equal('Xmemfile_test.c', @%) + endfor - " Test 9: Invalid find command - call assert_fails('cs find x', 'E560') + " Test 9: Find files #including this file + for cmd in ['cs find i assert.h', 'cs find 8 assert.h'] + enew + let a=execute(cmd) + call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <> #include '], split(a, '\n', 1)) + call assert_equal('#include ', getline('.')) + endfor - " Test 10: Find places where this symbol is assigned a value + " Test 10: Invalid find command + call assert_fails('cs find x', 'E560:') + + " Test 11: Find places where this symbol is assigned a value " this needs a cscope >= 15.8 " unfortunately, Travis has cscope version 15.7 let cscope_version=systemlist('cscope --version')[0] let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) if cs_version >= 15.8 - let a=execute('cscope find a item') - call assert_equal(['', '(1 of 4): <> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1)) - call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + for cmd in ['cs find a item', 'cs find 9 item'] + let a=execute(cmd) + call assert_equal(['', '(1 of 4): <> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1)) + call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + endfor endif - " Test 11: leading whitespace is not removed for cscope find text + " Test 12: leading whitespace is not removed for cscope find text let a=execute('cscope find t test_mf_hash') call assert_equal(['', '(1 of 1): <<>> test_mf_hash();'], split(a, '\n', 1)) call assert_equal(' test_mf_hash();', getline('.')) - " Test 12: cscope help - let a=execute('cscope help') - call assert_match('^cscope commands:\n', a) - call assert_match('\nadd :', a) - call assert_match('\nfind :', a) - call assert_match('\nhelp : Show this message', a) - call assert_match('\nkill : Kill a connection', a) - call assert_match('\nreset: Reinit all connections', a) - call assert_match('\nshow : Show connections', a) - - " Test 13: reset connections + " Test 13: test with scscope + let a=execute('scs find t Bram') + call assert_match('(1 of 1): <<>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a) + call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.')) + + " Test 14: cscope help + for cmd in ['cs', 'cs help', 'cs xxx'] + let a=execute(cmd) + call assert_match('^cscope commands:\n', a) + call assert_match('\nadd :', a) + call assert_match('\nfind :', a) + call assert_match('\nhelp : Show this message', a) + call assert_match('\nkill : Kill a connection', a) + call assert_match('\nreset: Reinit all connections', a) + call assert_match('\nshow : Show connections', a) + endfor + let a=execute('scscope help') + call assert_match('This cscope command does not support splitting the window\.', a) + + " Test 15: reset connections let a=execute('cscope reset') call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a) call assert_match('\nAll cscope databases reset', a) - " Test 14: cscope show + " Test 16: cscope show let a=execute('cscope show') call assert_match('\n 0 \d\+.*Xcscope.out\s*', a) - " Test 15: cstag and 'csto' option + " Test 17: cstag and 'csto' option set csto=0 let a=execute('cstag TEST_COUNT') call assert_match('(1 of 1): <> #define TEST_COUNT 50000', a) @@ -144,26 +173,104 @@ func Test_cscope1() let a=execute('cstag index_to_key') call assert_match('(1 of 1): <> #define index_to_key(i) ((i) ^ 15167)', a) call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.')) - call assert_fails('cstag xxx', 'E257') - call assert_fails('cstag', 'E562') - - " Test 15: 'csprg' option - call assert_equal('cscope', &csprg) + call assert_fails('cstag xxx', 'E257:') + call assert_fails('cstag', 'E562:') - " Test 16: 'cst' option + " Test 18: 'cst' option + set nocst + call assert_fails('tag TEST_COUNT', 'E426:') set cst let a=execute('tag TEST_COUNT') call assert_match('(1 of 1): <> #define TEST_COUNT 50000', a) call assert_equal('#define TEST_COUNT 50000', getline('.')) - set nocst - call assert_fails('tag TEST_COUNT', 'E426') + let a=execute('tags') + call assert_match('1 1 TEST_COUNT\s\+\d\+\s\+#define index_to_key', a) + + " Test 19: this should trigger call to cs_print_tags() + " Unclear how to check result though, we just exercise the code. + set cst cscopequickfix=s0 + call feedkeys(":cs find s main\", 't') + + " Test 20: cscope kill + call assert_fails('cscope kill 2', 'E261:') + call assert_fails('cscope kill xxx', 'E261:') + + let a=execute('cscope kill 0') + call assert_match('cscope connection 0 closed', a) + + cscope add Xcscope.out + let a=execute('cscope kill Xcscope.out') + call assert_match('cscope connection Xcscope.out closed', a) + + cscope add Xcscope.out . + let a=execute('cscope kill -1') + call assert_match('cscope connection .*Xcscope.out closed', a) + let a=execute('cscope kill -1') + call assert_equal('', a) + + " Test 21: 'csprg' option + call assert_equal('cscope', &csprg) + set csprg=doesnotexist + call assert_fails('cscope add Xcscope2.out', 'E609:') + set csprg=cscope + + " Test 22: multiple cscope connections + cscope add Xcscope.out + cscope add Xcscope2.out . -C + let a=execute('cscope show') + call assert_match('\n 0 \d\+.*Xcscope.out\s*', a) + call assert_match('\n 1 \d\+.*Xcscope2.out\s*\.', a) + + " Test 23: test Ex command line completion + call feedkeys(":cs \\\"\", 'tx') + call assert_equal('"cs add find help kill reset show', @:) + + call feedkeys(":scs \\\"\", 'tx') + call assert_equal('"scs find', @:) + + call feedkeys(":cs find \\\"\", 'tx') + call assert_equal('"cs find a c d e f g i s t', @:) + + call feedkeys(":cs kill \\\"\", 'tx') + call assert_equal('"cs kill -1 0 1', @:) + + call feedkeys(":cs add Xcscope\\\"\", 'tx') + call assert_equal('"cs add Xcscope.out Xcscope2.out', @:) + + " Test 24: cscope_connection() + call assert_equal(cscope_connection(), 1) + call assert_equal(cscope_connection(0, 'out'), 1) + call assert_equal(cscope_connection(0, 'xxx'), 1) + call assert_equal(cscope_connection(1, 'out'), 1) + call assert_equal(cscope_connection(1, 'xxx'), 0) + call assert_equal(cscope_connection(2, 'out'), 0) + call assert_equal(cscope_connection(3, 'xxx', '..'), 0) + call assert_equal(cscope_connection(3, 'out', 'xxx'), 0) + call assert_equal(cscope_connection(3, 'out', '.'), 1) + call assert_equal(cscope_connection(4, 'out', '.'), 0) " CleanUp call CscopeSetupOrClean(0) - " cscope command should fail after killing scope connection. - call assert_fails('cscope find s main', 'E567') +endfunc + +func Test_cscopequickfix() + set cscopequickfix=s-,g-,d+,c-,t+,e-,f0,i-,a- + call assert_equal('s-,g-,d+,c-,t+,e-,f0,i-,a-', &cscopequickfix) + call assert_fails('set cscopequickfix=x-', 'E474:') + call assert_fails('set cscopequickfix=s', 'E474:') + call assert_fails('set cscopequickfix=s7', 'E474:') + call assert_fails('set cscopequickfix=s-a', 'E474:') endfunc +func Test_withoutCscopeConnection() + call assert_equal(cscope_connection(), 0) + + call assert_fails('cscope find s main', 'E567:') + let a=execute('cscope show') + call assert_match('no cscope connections', a) +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index 73bdfc3116..e1999ecfd7 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -265,7 +265,7 @@ static int included_patches[] = { // 2178, // 2177, // 2176 NA - // 2175, + 2175, 2174, // 2173, // 2172, -- cgit From 971d0590be0e2981c9ce2fbdc2bb43150ad19869 Mon Sep 17 00:00:00 2001 From: rover Date: Sat, 7 Jan 2017 20:08:38 +0800 Subject: vim-patch:7.4.2295 Problem: Cscope test fails. Solution: Avoid checking for specific line and column numbers. https://github.com/vim/vim/commit/4792255eff03760dca0fd014616532e6d47db364 --- src/nvim/testdir/test_cscope.vim | 7 +++++-- src/nvim/version.c | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_cscope.vim b/src/nvim/testdir/test_cscope.vim index e9ed490372..4e78faa9fd 100644 --- a/src/nvim/testdir/test_cscope.vim +++ b/src/nvim/testdir/test_cscope.vim @@ -97,7 +97,7 @@ func Test_cscopeWithCscopeConnections() for cmd in ['cs find f Xmemfile_test.c', 'cs find 7 Xmemfile_test.c'] enew let a=execute(cmd) - call assert_match('\n"Xmemfile_test.c" 143L, 3137C', a) + call assert_true(a =~ '"Xmemfile_test.c" \d\+L, \d\+C') call assert_equal('Xmemfile_test.c', @%) endfor @@ -105,7 +105,10 @@ func Test_cscopeWithCscopeConnections() for cmd in ['cs find i assert.h', 'cs find 8 assert.h'] enew let a=execute(cmd) - call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <> #include '], split(a, '\n', 1)) + let alines = split(a, '\n', 1) + call assert_equal('', alines[0]) + call assert_true(alines[1] =~ '"Xmemfile_test.c" \d\+L, \d\+C') + call assert_equal('(1 of 1): <> #include ', alines[2]) call assert_equal('#include ', getline('.')) endfor diff --git a/src/nvim/version.c b/src/nvim/version.c index e1999ecfd7..6188bec91f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -145,7 +145,7 @@ static int included_patches[] = { // 2298 NA // 2297 NA // 2296, - // 2295, + 2295, 2294, // 2293, // 2292, -- cgit From 0b81addd0a7210485ef37a49355effc45b47954e Mon Sep 17 00:00:00 2001 From: rover Date: Sat, 7 Jan 2017 22:10:06 +0800 Subject: fix cscope test failure --- src/nvim/if_cscope.c | 5 +- src/nvim/testdir/samples/memfile_test.c | 143 ++++++++++++++++++++++++++++++++ src/nvim/testdir/test_cscope.vim | 2 +- 3 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 src/nvim/testdir/samples/memfile_test.c (limited to 'src') diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 0b20647771..9d50058257 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -1294,9 +1294,10 @@ static int cs_kill(exarg_T *eap) } } - if (i >= csinfo_size || csinfo[i].fname == NULL) { - if (p_csverbose) + if (!killall && (i >= csinfo_size || csinfo[i].fname == NULL)) { + if (p_csverbose) { (void)EMSG2(_("E261: cscope connection %s not found"), stok); + } return CSCOPE_FAILURE; } else { if (killall) { diff --git a/src/nvim/testdir/samples/memfile_test.c b/src/nvim/testdir/samples/memfile_test.c new file mode 100644 index 0000000000..0fa1e14c40 --- /dev/null +++ b/src/nvim/testdir/samples/memfile_test.c @@ -0,0 +1,143 @@ +/* vi:set ts=8 sts=4 sw=4 noet: + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. + */ + +/* + * memfile_test.c: Unittests for memfile.c + * Mostly by Ivan Krasilnikov. + */ + +#undef NDEBUG +#include + +/* Must include main.c because it contains much more than just main() */ +#define NO_VIM_MAIN +#include "main.c" + +/* This file has to be included because the tested functions are static */ +#include "memfile.c" + +#define index_to_key(i) ((i) ^ 15167) +#define TEST_COUNT 50000 + +/* + * Test mf_hash_*() functions. + */ + static void +test_mf_hash(void) +{ + mf_hashtab_T ht; + mf_hashitem_T *item; + blocknr_T key; + long_u i; + long_u num_buckets; + + mf_hash_init(&ht); + + /* insert some items and check invariants */ + for (i = 0; i < TEST_COUNT; i++) + { + assert(ht.mht_count == i); + + /* check that number of buckets is a power of 2 */ + num_buckets = ht.mht_mask + 1; + assert(num_buckets > 0 && (num_buckets & (num_buckets - 1)) == 0); + + /* check load factor */ + assert(ht.mht_count <= (num_buckets << MHT_LOG_LOAD_FACTOR)); + + if (i < (MHT_INIT_SIZE << MHT_LOG_LOAD_FACTOR)) + { + /* first expansion shouldn't have occurred yet */ + assert(num_buckets == MHT_INIT_SIZE); + assert(ht.mht_buckets == ht.mht_small_buckets); + } + else + { + assert(num_buckets > MHT_INIT_SIZE); + assert(ht.mht_buckets != ht.mht_small_buckets); + } + + key = index_to_key(i); + assert(mf_hash_find(&ht, key) == NULL); + + /* allocate and add new item */ + item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE); + assert(item != NULL); + item->mhi_key = key; + mf_hash_add_item(&ht, item); + + assert(mf_hash_find(&ht, key) == item); + + if (ht.mht_mask + 1 != num_buckets) + { + /* hash table was expanded */ + assert(ht.mht_mask + 1 == num_buckets * MHT_GROWTH_FACTOR); + assert(i + 1 == (num_buckets << MHT_LOG_LOAD_FACTOR)); + } + } + + /* check presence of inserted items */ + for (i = 0; i < TEST_COUNT; i++) + { + key = index_to_key(i); + item = mf_hash_find(&ht, key); + assert(item != NULL); + assert(item->mhi_key == key); + } + + /* delete some items */ + for (i = 0; i < TEST_COUNT; i++) + { + if (i % 100 < 70) + { + key = index_to_key(i); + item = mf_hash_find(&ht, key); + assert(item != NULL); + assert(item->mhi_key == key); + + mf_hash_rem_item(&ht, item); + assert(mf_hash_find(&ht, key) == NULL); + + mf_hash_add_item(&ht, item); + assert(mf_hash_find(&ht, key) == item); + + mf_hash_rem_item(&ht, item); + assert(mf_hash_find(&ht, key) == NULL); + + vim_free(item); + } + } + + /* check again */ + for (i = 0; i < TEST_COUNT; i++) + { + key = index_to_key(i); + item = mf_hash_find(&ht, key); + + if (i % 100 < 70) + { + assert(item == NULL); + } + else + { + assert(item != NULL); + assert(item->mhi_key == key); + } + } + + /* free hash table and all remaining items */ + mf_hash_free_all(&ht); +} + + int +main(void) +{ + test_mf_hash(); + return 0; +} diff --git a/src/nvim/testdir/test_cscope.vim b/src/nvim/testdir/test_cscope.vim index 4e78faa9fd..c8d2ebd7da 100644 --- a/src/nvim/testdir/test_cscope.vim +++ b/src/nvim/testdir/test_cscope.vim @@ -6,7 +6,7 @@ endif func CscopeSetupOrClean(setup) if a:setup - noa sp ../memfile_test.c + noa sp samples/memfile_test.c saveas! Xmemfile_test.c call system('cscope -bk -fXcscope.out Xmemfile_test.c') call system('cscope -bk -fXcscope2.out Xmemfile_test.c') -- cgit