Felipe Vieira wrote:
> Hi everyone,
>
> I've been trying to develop a plugin and I'm used to writing testing for the
> softwares I develop. The problem is that I cannot find a suitable testing
> platform for vim plugins. This makes me feel uncomfortable in pushing
> improvements made on my own fork of a bigger project (this may adversely 
> impact
> hundreds of users, and I think the codebase is complex enough; tests would
> force some adherence to what is already coded and improve the plugin itself).
>
> I have tried a couple of other vim plugins for testing with little/no success.
> <snip>
Have you tried pchk?  (http://www.drchip.org/astronaut/vim/index.html#PCHK)

The idea: create a file with a number of commands.

 * Run :PChkTry and fix your plugin until you have it working.  (your
plugin will be running in a separate vim window)
 * Run :PChkMake  -- this will, at every PChkSnapshot, take a hash of
the display of the remote vim window's contents and save it (along with
some geometry information, such as qty of windows, size of windows, etc)
 * In the future: use :PChk  -- that will compare the current plugin
performance with that of its previous performance (ie. if the hash is
the same, pretty much the display has not changed)

An excerpt from its help:

                *PChkTry* *PChkMake* *PChk* *PChkStep*
    Start a test by editing it, then run one of the following four commands:

    :PChkTry      : try the test.  Will stop at :PChkSnapshot lines
    :PChkMake      : make an Expected/tst###.out file
    :PChk          : compare snapshot hashes currently obtained
                with previously obtained expected test results
    :PChkStep      : step through each line of a test, not just at
              :PChkSnapshots.


    Test File Commands         *PChkSnapshot* *PChkFeedkeys* *PChkPause*

    :PChkSnapshot      : runs a hashing algorithm over the remote display.
                Result is saved in/compared with Expected/tst###.out
    :PChkFeedkeys ... : send keys to server.  ^X transla              
*PChkTry* *PChkMake* *PChk* *PChkStep*
    Start a test by editing it, then run one of the following four commands:

    :PChkTry      : try the test.  Will stop at :PChkSnapshot lines
    :PChkMake      : make an Expected/tst###.out file
    :PChk          : compare snapshot hashes currently obtained
                with previously obtained expected test results
    :PChkStep      : step through each line of a test, not just at
              :PChkSnapshots.


    Test File Commands         *PChkSnapshot* *PChkFeedkeys* *PChkPause*

    :PChkSnapshot      : runs a hashing algorithm over the remote display.
                Result is saved in/compared with Expected/tst###.out
    :PChkFeedkeys ... : send keys to server.  ^X translates to control
                characters (ie. ^M is a ENTER)
    :PChkPause      : pause the test (uses |input()|).  One may
                * <cr> =continue
                * c    =check
                * s    =step
                * t    =try
    :..cmd          : send cmd to server to execute..
    ^\s*#...      : echomsg comment in client vim (will not be sent
                to server)
    ..cmd..          : send cmd to server to execute as a normal command
    *..reply..      : netrw issues prompt; reply to it with this string
tes to control
                characters (ie. ^M is a ENTER)
    :PChkPause      : pause the test (uses |input()|).  One may
                * <cr> =continue
                * c    =check
                * s    =step
                * t    =try
    :..cmd          : send cmd to server to execute..
    ^\s*#...      : echomsg comment in client vim (will not be sent
                to server)
    ..cmd..          : send cmd to server to execute as a normal command
    *..reply..      : netrw issues prompt; reply to it with this string


An example of a test file (for netrw):  (in a file called tst003)

# Make a file: %  (called TmpFile)
# Delete the file
:let g:netrw_pchk= 1
:cd dir001
:e .
:PChkSnapshot
%
*TmpFile
:call setline(1,"testing")
:PChkSnapshot
:w
:e .
:PChkSnapshot
:call search("TmpFile","wc")
:PChkSnapshot
D
*y
:PChkSnapshot

The :... commands are vim commands.  Without a ":" are vim normal-mode
commands/maps.

Hope that helps,
Chip Campbell

-- 
-- 
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to