-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunMocha.vim
81 lines (68 loc) · 2.02 KB
/
runMocha.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
" run mocha and display results in the bottom window
" Maintainer: Etienne Rossignon
"
let mocharesult="/tmp/mocha.mytap"
let mochawin = -1
function! RunMocha()
" save current windows number
let g:old_win = winnr()
" auto save document in active window (if necessary)
silent! write!
if (g:mochawin == -1)
silent! !mkdir /tmp/test
" delete previous buffer
silent! execute "bd! " . g:mocharesult
call delete(g:mocharesult)
" create the test result at the bottom
silent! execute "botright new"
" slightly reduce the test output window
execute "normal 6\<C-W>-"
silent! execute "write! " . g:mocharesult
redraw
let g:mochawin = winnr()
"xx echo " mocha windows is " . g:mochawin
"xx sleep 3
endif
" activate test result window
execute "normal \<C-W>b"
" purge test result window
setlocal modifiable
execute "1,$d"
"xx silent! execute "bd! " . g:mocharesult
"xx execute "botright new"
"xx silent! execute "write! " . g:mocharesult
" execute command and store result in current buffer
cd /tmp
read !mocha -R tap
match Error /^not ok .*$/
match Question /^ok .*$/
match Special /^ok .*# SKIP -$/
match Question /^# fail 0$/
match Error /^# tests 0$/
highlight myTapOK ctermfg=Green ctermbg=Black
" clean up the result by removing cluttering lines
silent! 1,$g/Roaming/d
silent! 1,$g/node\.js/d
silent! 1,$g/module\.js/d
execute "0"
" make sure first failing test is visibile
if ( search("not ok") > 0 )
silent! execute "/not ok/"
else
silent! execute "/# tests/
endif
silent! execute "normal zz"
" apply syntax highlighting
set filetype=mytap
setlocal nomodifiable
write!
"xxx cgetbuffer " read eror list from current buffer
"xxx " build the quickfix list
redraw
"xxx cl " list all erro
"xxx copen
" " display error list
"reactivate old window
execute "normal \<C-W>t"
execute g:old_win . "wincmd w"
endfunction