Skip to content

Commit

Permalink
Moved into python file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Cairns committed May 4, 2012
1 parent 8fec6e3 commit 3b15930
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
28 changes: 28 additions & 0 deletions plugin/cakephp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
import sys
import vim
import re

def parse_test_output( ):
fd = open("/tmp/caketest_output")
found = False
parsing = False
k = 0
firsterr = -1
numfails = 0
for line in fd:
if k == firsterr:
parsing = True
if parsing:
print line
if found == True:
p = re.compile('There (?:were|was) ([0-9]*) failure',line)
m = p.match(line)
numfails = m.group(1)
firsterr = k+2
break
if "Time: " in line:
found = True
k = k + 1


23 changes: 20 additions & 3 deletions plugin/vim-cakephp.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
if filereadable($VIMRUNTIME."/plugin/cakephp.py")
pyfile $VIMRUNTIME/plugin/cakephp.py
elseif filereadable($HOME."/.vim/plugin/cakephp.py")
pyfile $HOME/.vim/plugin/cakephp.py
else
" when we use pathogen for instance
let $CUR_DIRECTORY=expand("<sfile>:p:h")

function! cakephp#RunTests(arg)
exe "caketest --no-colors ".a:arg
if filereadable($CUR_DIRECTORY."/cakephp.py")
pyfile $CUR_DIRECTORY/cakephp.py
else
call confirm('cakephp.vim: Unable to find cakephp.py. Place it in either your home vim directory or in the Vim runtime directory.', 'OK')
finish
endif
endif

command! -nargs=1 Test call s:RunCakePHPTests(<q-args>)

function! s:RunCakePHPTests(arg)
exe "!caketest --no-colors ".a:arg." | tee /tmp/caketest_output"
python parse_test_output()
endfunction

command! -nargs=1 Test call cakephp#RunTests(<args>)

0 comments on commit 3b15930

Please sign in to comment.