From 46c4d4ac66aa2b129f4dcec9debfda606f72d4b3 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 5 Aug 2016 19:31:57 +0200 Subject: [PATCH 1/5] patch 7.4.2157 Problem: Test_job_start_fails() is expected to report memory leaks, making it hard to see other leaks in test_partial. Solution: Move Test_job_start_fails() to a separate test file. --- src/Makefile | 1 + src/testdir/Make_all.mak | 1 + src/testdir/test_job_fails.vim | 19 +++++++++++++++++++ src/testdir/test_partial.vim | 22 ---------------------- src/version.c | 2 ++ 5 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 src/testdir/test_job_fails.vim diff --git a/src/Makefile b/src/Makefile index 273fc9ea99..3559659994 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2086,6 +2086,7 @@ test_arglist \ test_history \ test_increment \ test_increment_dbcs \ + test_job_fails \ test_join \ test_json \ test_jumps \ diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index 9493ccb40e..0ff00660ce 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -176,6 +176,7 @@ NEW_TESTS = test_arglist.res \ test_history.res \ test_increment.res \ test_increment_dbcs.res \ + test_job_fails.res \ test_json.res \ test_langmap.res \ test_man.res \ diff --git a/src/testdir/test_job_fails.vim b/src/testdir/test_job_fails.vim new file mode 100644 index 0000000000..ddab6a3160 --- /dev/null +++ b/src/testdir/test_job_fails.vim @@ -0,0 +1,19 @@ +" This test is in a separate file, because it usually causes reports for memory +" leaks under valgrind. That is because when fork/exec fails memory is not +" freed. Since the process exists right away it's not a real leak. + +source shared.vim + +func Test_job_start_fails() + if has('job') + let g:job = job_start('axdfxsdf') + if has('unix') + call WaitFor('job_status(g:job) == "dead"') + call assert_equal('dead', job_status(g:job)) + else + call WaitFor('job_status(g:job) == "fail"') + call assert_equal('fail', job_status(g:job)) + endif + unlet g:job + endif +endfunc diff --git a/src/testdir/test_partial.vim b/src/testdir/test_partial.vim index 6b098c2ddd..48c7697b47 100644 --- a/src/testdir/test_partial.vim +++ b/src/testdir/test_partial.vim @@ -1,27 +1,5 @@ " Test binding arguments to a Funcref. -" NOTE: This function may cause memory leaks to be reported. -" That is because when fork/exec fails memory is not freed. Since the process -" exists right away it's not a real leak. -func Test_job_start_fails() - if has('job') - let job = job_start('axdfxsdf') - for i in range(100) - let status = job_status(job) - if status == 'dead' || status == 'fail' - break - endif - sleep 10m - endfor - if has('unix') - call assert_equal('dead', job_status(job)) - else - call assert_equal('fail', job_status(job)) - endif - unlet job - endif -endfunc - func MyFunc(arg1, arg2, arg3) return a:arg1 . '/' . a:arg2 . '/' . a:arg3 endfunc diff --git a/src/version.c b/src/version.c index 17febd0562..c5511beeb3 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2157, /**/ 2156, /**/ From b650b9878e9f0ac6bb1b61230095ad9ab3850a33 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 5 Aug 2016 20:35:13 +0200 Subject: [PATCH 2/5] patch 7.4.2158 Problem: Result of getcompletion('', 'cscope') depends on previous completion. (Christian Brabandt) Solution: Call set_context_in_cscope_cmd(). --- src/evalfunc.c | 7 +++++++ src/testdir/test_cmdline.vim | 16 +++++++++++++--- src/version.c | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/evalfunc.c b/src/evalfunc.c index b6f05b14cb..00956612f8 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -4240,6 +4240,13 @@ f_getcompletion(typval_T *argvars, typval_T *rettv) xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); } # endif +#ifdef FEAT_CSCOPE + if (xpc.xp_context == EXPAND_CSCOPE) + { + set_context_in_cscope_cmd(&xpc, xpc.xp_pattern, CMD_cscope); + xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern); + } +#endif pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); if ((rettv_list_alloc(rettv) != FAIL) && (pat != NULL)) diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index c6d416f1e6..12194cd963 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -125,12 +125,22 @@ func Test_getcompletion() let l = getcompletion('dark', 'highlight') call assert_equal([], l) + if has('cscope') + let l = getcompletion('', 'cscope') + let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show'] + call assert_equal(cmds, l) + " using cmdline completion must not change the result + call feedkeys(":cscope find \\", 'xt') + let l = getcompletion('', 'cscope') + call assert_equal(cmds, l) + let keys = ['a', 'c', 'd', 'e', 'f', 'g', 'i', 's', 't'] + let l = getcompletion('find ', 'cscope') + call assert_equal(keys, l) + endif + " For others test if the name is recognized. let names = ['buffer', 'environment', 'file_in_path', \ 'mapping', 'shellcmd', 'tag', 'tag_listfiles', 'user'] - if has('cscope') - call add(names, 'cscope') - endif if has('cmdline_hist') call add(names, 'history') endif diff --git a/src/version.c b/src/version.c index c5511beeb3..31aa1e9a2e 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2158, /**/ 2157, /**/ From 5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 5 Aug 2016 21:25:29 +0200 Subject: [PATCH 3/5] patch 7.4.2159 Problem: Insufficient testing for cscope. Solution: Add more tests. (Dominique Pelle) --- src/testdir/test_cscope.vim | 43 +++++++++++++++++++++++++++++++------ src/version.c | 2 ++ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/testdir/test_cscope.vim b/src/testdir/test_cscope.vim index 0beeb058bb..2c7ed9fcce 100644 --- a/src/testdir/test_cscope.vim +++ b/src/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/version.c b/src/version.c index 31aa1e9a2e..1c83d6e7b8 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2159, /**/ 2158, /**/ From 7dc5e2e486fe0287601968e535902a41a39f65bb Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 5 Aug 2016 22:22:06 +0200 Subject: [PATCH 4/5] patch 7.4.2160 Problem: setmatches() mixes up values. (Nikolai Pavlov) Solution: Save the string instead of reusing a shared buffer. --- src/dict.c | 1 + src/evalfunc.c | 6 ++++-- src/testdir/test_expr.vim | 9 +++++++++ src/version.c | 2 ++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/dict.c b/src/dict.c index 9c590064cc..30a15a6f07 100644 --- a/src/dict.c +++ b/src/dict.c @@ -418,6 +418,7 @@ dict_find(dict_T *d, char_u *key, int len) /* * Get a string item from a dictionary. * When "save" is TRUE allocate memory for it. + * When FALSE a shared buffer is used, can only be used once! * Returns NULL if the entry doesn't exist or out of memory. */ char_u * diff --git a/src/evalfunc.c b/src/evalfunc.c index 00956612f8..dc0e630af8 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -9659,11 +9659,11 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED) } } - group = get_dict_string(d, (char_u *)"group", FALSE); + group = get_dict_string(d, (char_u *)"group", TRUE); priority = (int)get_dict_number(d, (char_u *)"priority"); id = (int)get_dict_number(d, (char_u *)"id"); conceal = dict_find(d, (char_u *)"conceal", -1) != NULL - ? get_dict_string(d, (char_u *)"conceal", FALSE) + ? get_dict_string(d, (char_u *)"conceal", TRUE) : NULL; if (i == 0) { @@ -9677,6 +9677,8 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED) list_unref(s); s = NULL; } + vim_free(group); + vim_free(conceal); li = li->li_next; } diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 0800039aee..557d74960f 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -194,3 +194,12 @@ func Test_funcref() let OneByRef = funcref('One') call assert_equal(2, OneByRef()) endfunc + +func Test_setmatches() + hi def link 1 Comment + hi def link 2 PreProc + let set = [{"group": 1, "pattern": 2, "id": 3, "priority": 4, "conceal": 5}] + let exp = [{"group": '1', "pattern": '2', "id": 3, "priority": 4, "conceal": '5'}] + call setmatches(set) + call assert_equal(exp, getmatches()) +endfunc diff --git a/src/version.c b/src/version.c index 1c83d6e7b8..94e14bff86 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2160, /**/ 2159, /**/ From 7ab6defcafe017a3ad58580a3e56dab705b1ed8b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 5 Aug 2016 22:51:13 +0200 Subject: [PATCH 5/5] patch 7.4.2161 Problem: Expression test fails without conceal feature. Solution: Only check "conceal" with the conceal feature. --- src/testdir/test_expr.vim | 8 ++++++-- src/version.c | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 557d74960f..cd71c419a1 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -198,8 +198,12 @@ endfunc func Test_setmatches() hi def link 1 Comment hi def link 2 PreProc - let set = [{"group": 1, "pattern": 2, "id": 3, "priority": 4, "conceal": 5}] - let exp = [{"group": '1', "pattern": '2', "id": 3, "priority": 4, "conceal": '5'}] + let set = [{"group": 1, "pattern": 2, "id": 3, "priority": 4}] + let exp = [{"group": '1', "pattern": '2', "id": 3, "priority": 4}] + if has('conceal') + let set[0]['conceal'] = 5 + let exp[0]['conceal'] = '5' + endif call setmatches(set) call assert_equal(exp, getmatches()) endfunc diff --git a/src/version.c b/src/version.c index 94e14bff86..e68df1f5ac 100644 --- a/src/version.c +++ b/src/version.c @@ -763,6 +763,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2161, /**/ 2160, /**/