Loading ...
Sorry, an error occurred while loading the content.
 

Re: building a test case with netbeans

Expand Messages
  • Xavier de Gaye
    ... Yes, this is right. It is a bit complicated due to the fact that there are three processes running asynchronously (Vim, pyclewn and gdb), so it is better
    Message 1 of 3 , Oct 1, 2011
      On Fri, Sep 30, 2011 at 4:12 PM, Bram Moolenaar wrote:
      > Xavier de Gaye wrote:
      >> ...
      >> When building an automated test case with netbeans, it is not obvious
      >> how to have Vim made to call the idle loop. The attached patch adds a
      >> call to netbeans_parse_messages() when the Vim ":sleep" command is
      >> run. This allows for a more deterministic way of writing the test
      >> cases (instead of inserting ":sleep" commands randomly until it works,
      >> on this hardware).
      >
      > OK, this makes sense.  So you would run a Vim script that calls sleep in
      > an endless loop?


      Yes, this is right. It is a bit complicated due to the fact that there
      are three processes running asynchronously (Vim, pyclewn and gdb), so
      it is better to give an example. A typical pyclewn test case checks
      that the content of a ${test_out} file contains the expected Vim signs
      list:

      * the test starts by running the sequence of Vim and pyclewn
      commands that triggers gdb and sets breakpoint signs in Vim
      buffers
      * the test ends with the following commands:

      :call Wait_eop()
      :redir! > ${test_out}
      :sign place
      :qa

      * the definition of Wait_eop() follows:

      # wait for pyclewn to process all previous commands
      WAIT_EOP = """
      :let g:testrun_key = ${key}
      :function Wait_eop()
      : let g:testrun_key += 1
      : exe "Cdumprepr " . ${eop_file} . " " . g:testrun_key
      : let l:start = localtime()
      : while 1
      : " allow vim to process netbeans events and messages
      : sleep 10m
      : if localtime() - l:start > 5
      : break
      : endif
      : if filereadable(${eop_file})
      : let l:lines = readfile(${eop_file})
      : if len(lines) && l:lines[0] == g:testrun_key
      : sleep ${time}m
      : break
      : endif
      : endif
      : endwhile
      :endfunction
      """

      The call to the pyclewn 'Cdumprepr' command in Wait_eop() causes
      pyclewn to create the temporary file named ${eop_file} and to write in
      this file the value of ${key}. Thus, Wait_eop() can break out of the
      while loop when detecting that the ${eop_file} contains the ${key},
      which means that gdb and pyclewn have completed all their tasks. Note
      that Wait_eop() still needs to sleep ${time} milliseconds, just before
      the 'break' statement, to make sure that netbeans in Vim has processed
      all the netbeans messages and has completed its share of the tasks.


      > Please add a note in the documentation about this.  And perhaps a hint
      > in the netbeans interface about what you are doing, it would be useful
      > to others.


      See the attached patch updated with documentation. I have also added a
      paragraph to the ":nbkey" command to explain that it can be used to
      pass any text to the IDE.


      --
      Xavier

      Les Chemins de Lokoti: http://lokoti.alwaysdata.net

      --
      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
    Your message has been successfully submitted and would be delivered to recipients shortly.