summaryrefslogtreecommitdiffstats
path: root/syntax/tap.vim
blob: 1cdcde10a32138c9199772b4770b6cb076045aa1 (plain) (blame)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'vim') == -1
  
" Vim syntax file
" Language:    Verbose TAP Output
" Maintainer:  Rufus Cable <rufus@threebytesfull.com>
" Remark:      Simple syntax highlighting for TAP output
" License:
" Copyright:   (c) 2008-2013 Rufus Cable
" Last Change: 2014-12-13

if exists("b:current_syntax")
  finish
endif

syn match tapTestDiag /^ *#.*/ contains=tapTestTodo
syn match tapTestTime /^ *\[\d\d:\d\d:\d\d\].*/ contains=tapTestFile
syn match tapTestFile /\w\+\/[^. ]*/ contained
syn match tapTestFileWithDot /\w\+\/[^ ]*/ contained

syn match tapTestPlan /^ *\d\+\.\.\d\+$/

" tapTest is a line like 'ok 1', 'not ok 2', 'ok 3 - xxxx'
syn match tapTest /^ *\(not \)\?ok \d\+.*/ contains=tapTestStatusOK,tapTestStatusNotOK,tapTestLine

" tapTestLine is the line without the ok/not ok status - i.e. number and
" optional message
syn match tapTestLine /\d\+\( .*\|$\)/ contains=tapTestNumber,tapTestLoadMessage,tapTestTodo,tapTestSkip contained

" turn ok/not ok messages green/red respectively
syn match tapTestStatusOK /ok/ contained
syn match tapTestStatusNotOK /not ok/ contained

" highlight todo tests
syn match tapTestTodo /\(# TODO\|Failed (TODO)\) .*$/ contained contains=tapTestTodoRev
syn match tapTestTodoRev /\<TODO\>/ contained

" highlight skipped tests
syn match tapTestSkip /# skip .*$/ contained contains=tapTestSkipTag
syn match tapTestSkipTag /\(# \)\@<=skip\>/ contained

" look behind so "ok 123" and "not ok 124" match test number
syn match tapTestNumber /\(ok \)\@<=\d\d*/ contained
syn match tapTestLoadMessage /\*\*\*.*\*\*\*/ contained contains=tapTestThreeStars,tapTestFileWithDot
syn match tapTestThreeStars /\*\*\*/ contained

syn region tapTestRegion start=/^ *\(not \)\?ok.*$/me=e+1 end=/^\(\(not \)\?ok\|# Looks like you planned \|All tests successful\|Bailout called\)/me=s-1 fold transparent excludenl
syn region tapTestResultsOKRegion start=/^\(All tests successful\|Result: PASS\)/ end=/$/
syn region tapTestResultsNotOKRegion start=/^\(# Looks like you planned \|Bailout called\|# Looks like you failed \|Result: FAIL\)/ end=/$/
syn region tapTestResultsSummaryRegion start=/^Test Summary Report/ end=/^Files=.*$/ contains=tapTestResultsSummaryHeading,tapTestResultsSummaryNotOK

syn region tapTestResultsSummaryHeading start=/^Test Summary Report/ end=/^-\+$/ contained
syn region tapTestResultsSummaryNotOK start=/TODO passed:/ end=/$/ contained

syn region tapTestInstructionsRegion start=/\%1l/ end=/^$/

set foldtext=TAPTestLine_foldtext()
function! TAPTestLine_foldtext()
    let line = getline(v:foldstart)
    let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
    return sub
endfunction

set foldminlines=5
set foldcolumn=2
set foldenable
set foldmethod=syntax
syn sync fromstart

if !exists("did_tapverboseoutput_syntax_inits")
  let did_tapverboseoutput_syntax_inits = 1

  hi      tapTestStatusOK    term=bold    ctermfg=green                 guifg=Green
  hi      tapTestStatusNotOK term=reverse ctermfg=black  ctermbg=red    guifg=Black     guibg=Red
  hi      tapTestTodo        term=bold    ctermfg=yellow ctermbg=black  guifg=Yellow    guibg=Black
  hi      tapTestTodoRev     term=reverse ctermfg=black  ctermbg=yellow guifg=Black     guibg=Yellow
  hi      tapTestSkip        term=bold    ctermfg=lightblue             guifg=LightBlue
  hi      tapTestSkipTag     term=reverse ctermfg=black  ctermbg=lightblue guifg=Black  guibg=LightBlue
  hi      tapTestTime        term=bold    ctermfg=blue                  guifg=Blue
  hi      tapTestFile        term=reverse ctermfg=black  ctermbg=yellow guibg=Black     guifg=Yellow
  hi      tapTestLoadedFile  term=bold    ctermfg=black  ctermbg=cyan   guibg=Cyan      guifg=Black
  hi      tapTestThreeStars  term=reverse ctermfg=blue                                  guifg=Blue
  hi      tapTestPlan        term=bold    ctermfg=yellow                                guifg=Yellow

  hi link tapTestFileWithDot tapTestLoadedFile
  hi link tapTestNumber      Number
  hi link tapTestDiag        Comment

  hi tapTestRegion ctermbg=green

  hi tapTestResultsOKRegion ctermbg=green ctermfg=black
  hi tapTestResultsNotOKRegion ctermbg=red ctermfg=black

  hi tapTestResultsSummaryHeading ctermbg=blue ctermfg=white
  hi tapTestResultsSummaryNotOK ctermbg=red ctermfg=black

  hi tapTestInstructionsRegion ctermbg=lightmagenta ctermfg=black
endif

let b:current_syntax="tapVerboseOutput"

endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'perl') == -1
  
" Vim syntax file
" Language:    Verbose TAP Output
" Maintainer:  Rufus Cable <rufus@threebytesfull.com>
" Remark:      Simple syntax highlighting for TAP output
" License:
" Copyright:   (c) 2008-2013 Rufus Cable
" Last Change: {{LAST_CHANGE}}

if exists("b:current_syntax")
  finish
endif

syn match tapTestDiag /^ *#.*/ contains=tapTestTodo
syn match tapTestTime /^ *\[\d\d:\d\d:\d\d\].*/ contains=tapTestFile
syn match tapTestFile /\w\+\/[^. ]*/ contained
syn match tapTestFileWithDot /\w\+\/[^ ]*/ contained

syn match tapTestPlan /^ *\d\+\.\.\d\+$/

" tapTest is a line like 'ok 1', 'not ok 2', 'ok 3 - xxxx'
syn match tapTest /^ *\(not \)\?ok \d\+.*/ contains=tapTestStatusOK,tapTestStatusNotOK,tapTestLine

" tapTestLine is the line without the ok/not ok status - i.e. number and
" optional message
syn match tapTestLine /\d\+\( .*\|$\)/ contains=tapTestNumber,tapTestLoadMessage,tapTestTodo,tapTestSkip contained

" turn ok/not ok messages green/red respectively
syn match tapTestStatusOK /ok/ contained
syn match tapTestStatusNotOK /not ok/ contained

" highlight todo tests
syn match tapTestTodo /\(# TODO\|Failed (TODO)\) .*$/ contained contains=tapTestTodoRev
syn match tapTestTodoRev /\<TODO\>/ contained

" highlight skipped tests
syn match tapTestSkip /# skip .*$/ contained contains=tapTestSkipTag
syn match tapTestSkipTag /\(# \)\@<=skip\>/ contained

" look behind so "ok 123" and "not ok 124" match test number
syn match tapTestNumber /\(ok \)\@<=\d\d*/ contained
syn match tapTestLoadMessage /\*\*\*.*\*\*\*/ contained contains=tapTestThreeStars,tapTestFileWithDot
syn match tapTestThreeStars /\*\*\*/ contained

syn region tapTestRegion start=/^ *\(not \)\?ok.*$/me=e+1 end=/^\(\(not \)\?ok\|# Looks like you planned \|All tests successful\|Bailout called\)/me=s-1 fold transparent excludenl
syn region tapTestResultsOKRegion start=/^\(All tests successful\|Result: PASS\)/ end=/$/
syn region tapTestResultsNotOKRegion start=/^\(# Looks like you planned \|Bailout called\|# Looks like you failed \|Result: FAIL\)/ end=/$/
syn region tapTestResultsSummaryRegion start=/^Test Summary Report/ end=/^Files=.*$/ contains=tapTestResultsSummaryHeading,tapTestResultsSummaryNotOK

syn region tapTestResultsSummaryHeading start=/^Test Summary Report/ end=/^-\+$/ contained
syn region tapTestResultsSummaryNotOK start=/TODO passed:/ end=/$/ contained

syn region tapTestInstructionsRegion start=/\%1l/ end=/^$/

set foldtext=TAPTestLine_foldtext()
function! TAPTestLine_foldtext()
    let line = getline(v:foldstart)
    let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
    return sub
endfunction

set foldminlines=5
set foldcolumn=2
set foldenable
set foldmethod=syntax
syn sync fromstart

if !exists("did_tapverboseoutput_syntax_inits")
  let did_tapverboseoutput_syntax_inits = 1

  hi      tapTestStatusOK    term=bold    ctermfg=green                 guifg=Green
  hi      tapTestStatusNotOK term=reverse ctermfg=black  ctermbg=red    guifg=Black     guibg=Red
  hi      tapTestTodo        term=bold    ctermfg=yellow ctermbg=black  guifg=Yellow    guibg=Black
  hi      tapTestTodoRev     term=reverse ctermfg=black  ctermbg=yellow guifg=Black     guibg=Yellow
  hi      tapTestSkip        term=bold    ctermfg=lightblue             guifg=LightBlue
  hi      tapTestSkipTag     term=reverse ctermfg=black  ctermbg=lightblue guifg=Black  guibg=LightBlue
  hi      tapTestTime        term=bold    ctermfg=blue                  guifg=Blue
  hi      tapTestFile        term=reverse ctermfg=black  ctermbg=yellow guibg=Black     guifg=Yellow
  hi      tapTestLoadedFile  term=bold    ctermfg=black  ctermbg=cyan   guibg=Cyan      guifg=Black
  hi      tapTestThreeStars  term=reverse ctermfg=blue                                  guifg=Blue
  hi      tapTestPlan        term=bold    ctermfg=yellow                                guifg=Yellow

  hi link tapTestFileWithDot tapTestLoadedFile
  hi link tapTestNumber      Number
  hi link tapTestDiag        Comment

  hi tapTestRegion ctermbg=green

  hi tapTestResultsOKRegion ctermbg=green ctermfg=black
  hi tapTestResultsNotOKRegion ctermbg=red ctermfg=black

  hi tapTestResultsSummaryHeading ctermbg=blue ctermfg=white
  hi tapTestResultsSummaryNotOK ctermbg=red ctermfg=black

  hi tapTestInstructionsRegion ctermbg=lightmagenta ctermfg=black
endif

let b:current_syntax="tapVerboseOutput"

endif