1 " Testing is manual for now, but aided by this simple script. Run like so:
     
2 "
     
3 "   1. Be in VViki project dir (e.g. cd ~/coolstuff/vviki/)
     
4 "   2. Run this script to start testing (vim -S test/test.vim)
     
5 "   3. Follow the instructions
     
6 "
     
7 " Note that this test script may mess up your current session. It can't
     
8 " be bargained with. It can't be reasoned with. It doesn't feel pity, or
     
9 " remorse, or fear.
    
10 "
    
11 
    12 nnoremap <f5> :call LoadTest()<cr>
    
13 nnoremap <right> :call NextTest()<cr>
    
14 nnoremap <left> :call PrevTest()<cr>
    
15 
    16 function! ReloadPlugin()
    
17     " Reload plugin and reset settings to defaults
    
18     unlet! g:loaded_vviki
    
19     unlet! g:vviki_index
    
20 	unlet! g:vviki_ext
    
21     unlet! g:vviki_conceal_links
    
22     unlet! g:vviki_page_link_syntax
    
23     unlet! g:vviki_visual_link_creation
    
24     unlet! g:vviki_links_include_ext
    
25     " Set wiki root directory for tests (relative to current dir)
    
26     let g:vviki_root = getcwd()."/test"
    
27 
    28     source plugin/vviki.vim
    
29 endfunction
    
30 
    31 function! LoadTest()
    
32     call ReloadPlugin()
    
33 
    34     let src_doc = expand("test/test_".s:current_test_num.".adoc")
    
35     let test_script = expand("test/current_script.vim")
    
36     let test_doc = expand("test/current_doc.adoc")
    
37 
    38     if !filereadable(src_doc)
    
39         echo "Test ".src_doc." not found. Perhaps we are all done?"
    
40         return
    
41     endif
    
42 
    43     " Let's make a new script to execute for the current test
    
44     silent execute "edit ".test_script
    
45     " Clear file
    
46     silent %delete
    
47     " Read current script
    
48     silent execute "read ".src_doc
    
49     " Delete everything except the test script in the file
    
50     silent execute "normal! /Test Script Start\<cr>"
    
51     silent 0,delete
    
52     silent execute "normal! /Test Script End\<cr>"
    
53     silent ,$delete
    
54     silent write
    
55     silent source %
    
56 
    57     " Let's make a new document to view for the current test
    
58     silent execute "edit ".test_doc
    
59     silent %delete
    
60     silent execute "read ".src_doc
    
61     silent write
    
62 
    63     " Because the autocommands will not fire because we're re-using
    
64     " the current test doc filename, we need to call the setup function
    
65     " manually. Should be identical to opening a new file.
    
66     call VVSetup()
    
67 
    68     echo "Test ".s:current_test_num." loaded."
    
69 endfunction
    
70 
    71 function! NextTest()
    
72     let s:current_test_num += 1
    
73     call LoadTest()
    
74 endfunction
    
75 
    76 function! PrevTest()
    
77     let s:current_test_num -= 1
    
78     call LoadTest()
    
79 endfunction
    
80 
    81 " Create buffers in a split to display messages and wiki test pages.
    
82 let s:current_test_num = 1
    
83 call LoadTest()