On Fr, 29 Jul 2016, vim-dev ML wrote: > On Fr, 29 Jul 2016, vim-dev ML wrote: > > > On Fr, 29 Jul 2016, Christian Brabandt wrote: > > > > > This includes a test for the cscope interface. Creating a PR here, so we > > > can see, how the travis and coverage works. > > > You can view, comment on, or merge this pull request online at: > > > > Hmpf, travis does currently not allow to install the package cscope. I > > opened a PR at github.com/travis-ci/apt-package-whitelist > > > > But until this is resolved, we can't expect coverage to increase. > > However, it should be safe to include it.
Okay, Travis now allows to install cscope. Updated patch attached. Needed some adjustments, since travis cscope does not support finding assignments. Coverage went up to 45.46 % for if_cscope.c That is not great, however a good improvement. I'll leave further improvements for later. Best, Christian -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
From eb34026f23d676a2bc3d31ddea621f8b3e187954 Mon Sep 17 00:00:00 2001 From: Christian Brabandt <[email protected]> Date: Fri, 29 Jul 2016 19:51:31 +0200 Subject: [PATCH] Test cscope interface (amended commit, since cscope is now available on travis-ci). Hopefully, coverage goes up now. Test cscope assignment only when cscope version >= 15.8 --- .travis.yml | 1 + src/testdir/test_cscope.vim | 127 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 127 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 13ad376..0acbf90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,6 +62,7 @@ addons: - python3-dev - liblua5.1-0-dev - lua5.1 + - cscope before_install: - pip install --user cpp-coveralls diff --git a/src/testdir/test_cscope.vim b/src/testdir/test_cscope.vim index b6d70f0..3dc82ff 100644 --- a/src/testdir/test_cscope.vim +++ b/src/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>> 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>> 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): <<main>> 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): <<<unknown>>> \* 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): <<<unknown>>> #include <assert.h>', a) + call assert_equal('#include <assert.h>', 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): <<global>> #include <assert.h>'], split(a, '\n', 1)) + call assert_equal('#include <assert.h>', 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): <<test_mf_hash>> 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): <<<unknown>>> 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*<none>', a) + + " Test 14: 'csprg' option + call assert_equal('cscope', &csprg) + + " CleanUp + call CscopeSetupOrClean(0) +endfunc + +" vim: tabstop=2 shiftwidth=0 sts=-1 expandtab -- 2.1.4
