Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Bug Report and a Patch on pytest'vspec/signatures.vim failed' #1134

Open
gyx47 opened this issue Jan 23, 2025 · 0 comments
Open

Test Bug Report and a Patch on pytest'vspec/signatures.vim failed' #1134

gyx47 opened this issue Jan 23, 2025 · 0 comments

Comments

@gyx47
Copy link

gyx47 commented Jan 23, 2025

Description:

There is a problem with the test code of the vim-jedi 0.11.2-3 package. The package build failed under both the riscv64 and x86-64 architectures. According to the log output, the signature test file reported an error when entering the test phase.

<buffer=5>
call jedi#clear_call_signatures()
        Last set from ~/vim-jedi/jedi-vim-0.11.2/autoload/jedi.vim line 604
if exists('b:_jedi_orig_updatetime') |   let &updatetime = b:_jedi_orig_updatetime |   unlet b:_jedi_orig_updatetime | endif
        Last set from ~/vim-jedi/jedi-vim-0.11.2/autoload/jedi.vim line 608
ok 2 - signatures multiple buffers
2 buffers wiped out
ok 3 - signatures simple after CursorHoldI with only parenthesis
ok 4 - signatures highlights correct argument
ok 5 - signatures no signature
ok 6 - signatures signatures disabled
staticmethod(f: Callable[..., Any])
foo(a, b)
ok 7 - signatures command line simple
not ok 8 - signatures command line truncation
 Expected Signature() == "\n".funcname."(arg1, …)" at line 15
     Actual value: "\n"
     Expected value: "\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(arg1, …)"
ok 9 - signatures command line no signature
FAILED test_integration.py::test_integration[vspec/signatures.vim] - Failed: vspec/signatures.vim failed:
======================================= 1 failed, 7 passed, 3 warnings in 6.73s ============================
  • package version(s):vim-jedi 0.11.2-3,Attached is a patch:python-3.13-accept-test-results.patch
  • config and/or log files:

vim-jedi-0.11.2-3-riscv64-prepare.log

vim-jedi-0.11.2-3-riscv64-check.log

My operating environment is an x86-64 environment virtual machine of the arch architecture of Windows WSL.
The process is as follows:

  1. I cloned your project and installed the dependencies
  2. Then execute py.test
  3. Wait for about 7 seconds and find an error

Patch

I modified the test file. Here are my ideas for modification:

This is the relevant code for the command line truncation error in the eighth test of /test/vsepr/sinagature.vim

it 'command line truncation'
        let g:jedi#show_call_signatures = 2
        call jedi#configure_call_signatures()

        function! Signature()
            redir => msg
            python3 jedi_vim.show_call_signatures()
            redir END
            return msg
        endfunction

        let funcname = repeat('a', &columns - (30 + (&ruler ? 18 : 0)))
        put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
        put = '    pass'
        execute "normal o\<BS>".funcname."( "
        Expect Signature() == "\n".funcname."(arg1, …)"

        exe 'normal sarg1, '
        Expect Signature() == "\n".funcname."(…, arg2, …)"

        exe 'normal sarg2, arg3, '
        Expect Signature() == "\n".funcname."(…, a, b, c)"

        exe 'normal sa, b, '
        Expect Signature() == "\n".funcname."(…, c)"

        g/^/d
        put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
        put = '    pass'
        execute "normal o\<BS>".funcname."( "
        Expect Signature() == "\n".funcname."(…)"
    end

Here is the relevant code for the show_call_signatures function called by this test

def show_call_signatures(signatures=()):
    if int(vim_eval("has('conceal') && g:jedi#show_call_signatures")) == 0:
        return

    #We need to clear the signatures before we calculate them again. The
    #reason for this is that call signatures are unfortunately written to the
    #buffer.
    clear_call_signatures()
    if signatures == ():
        signatures = get_script().get_signatures(*get_pos())

    if not signatures:
        return

    if int(vim_eval("g:jedi#show_call_signatures")) == 2:
        return cmdline_call_signatures(signatures)
…

After debugging, I found that according to the original test code, the process should have entered the fourth if function to execute g:jedi#show_call_signatures = 2, but in fact it returned in the third if, and no content was output, resulting in the return of \n.
The reason is that signatures = get_script().get_signatures(*get_pos()) is an empty list
And the signature cannot be read. I think it is related to <BS> returning to the end of the previous line and directly inputting, and it is impossible to return the signature according to the independently input function name.

I deleted the <BS> in the code in the patch, and then performed the same operation as above,

let funcname = repeat('a', &columns - (30 + (&ruler ? 18 : 0)))
        put = 'def '.funcname.'(arg1, arg2, arg3, a, b, c):'
        put = '    pass'
        execute "normal o".funcname."( "
        Expect Signature() == "\n".funcname."(arg1, …)"

        exe 'normal sarg1, '
        Expect Signature() == "\n".funcname."(…, arg2, …)"

        exe 'normal sarg2, arg3, '
        Expect Signature() == "\n".funcname."(…, a, b, c)"

        exe 'normal sa, b, '
        Expect Signature() == "\n".funcname."(…, c)"

        g/^/d
        put = 'def '.funcname.'('.repeat('b', 20).', arg2):'
        put = '    pass'
        execute "normal o".funcname."( "
        Expect Signature() == "\n".funcname."(…)"

and found that the test passed

Do you think this is a good change? If you think it is, I will open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant