Skip to content

Commit

Permalink
Fixed parsing for autoload functions and non .. functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsummersl committed Feb 7, 2013
1 parent 20aabe1 commit 35ffbba
Show file tree
Hide file tree
Showing 3 changed files with 2,100 additions and 16 deletions.
4 changes: 4 additions & 0 deletions autoload/vimunit/test.vim
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ fun TestParseVerboseFile()
call VULog(string(lines))
call VUAssertEquals(lines['mvom#renderer#CombineData']['status'],'aborted')
call VUAssertEquals(lines['mvom#renderer#CombineData']['offset'], 46)

" test yet another scenario that doesn't work.
let lines = vimunit#util#parseVerboseFile('autoload/vimunit/verr-TestSearchInWindow.txt')
call VUAssertEquals(lines['TestSearchInWindow']['offset'],28)
endf

function! TestGetCurrentFunctionNames()
Expand Down
40 changes: 24 additions & 16 deletions autoload/vimunit/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -194,28 +194,20 @@ function! vimunit#util#parseVerboseFile(filename)
let results = {}
let currentfunction = ''
for line in readfile(a:filename)
call VULog('line = '. line)
"call VULog('line = '. line)

if currentfunction != '' && !has_key(results,currentfunction)
let results[currentfunction] = {}
let results[currentfunction]['status'] = 'unknown'
let results[currentfunction]['detail'] = ''
endif

if line =~ '^\v\s*calling function.*\.\.[^(]+\([^)]*\)$'
let currentfunction = substitute(line,'^\v\s*calling function.*\.\.([^(]+)\([^)]*\)$','\=submatch(1)','')
" if the key doesn't exist, set it up
if !has_key(results,currentfunction)
let results['_count_'. currentfunction] = 1
else
" if it does exist, set it up, and give it a new unique key
let results['_count_'. currentfunction] += 1
let currentfunction = currentfunction .'('. results['_count_'. currentfunction] .')'
endif
let results[currentfunction] = {}
let results[currentfunction]['status'] = 'unknown'
let results[currentfunction]['detail'] = ''
call VULog('currentfunction = "'. currentfunction .'"')
if line =~ '^\v\s*calling function.*\.\.([^(]+)\([^)]*\)$'
let currentfunction = s:setupkey(line,results,'^\v\s*calling function.*\.\.([^(]+)\([^)]*\)$')
elseif line =~ '^\v\s*calling function ([^(]+)\([^)]*\)$'
let currentfunction = s:setupkey(line,results, '^\v\s*calling function ([^(]+)\([^)]*\)$')
elseif line =~ '^\v\s*autocommand call ([^(]+)\(\)'
let currentfunction = s:setupkey(line,results, '^\v\s*autocommand call ([^(]+)\(\)')
elseif line =~ 'continuing in function'
let currentfunction = substitute(line,'^\v\s*continuing in function .*<([^. (]+)$','\=submatch(1)','')
call VULog('currentfunction = "'. currentfunction .'"')
Expand Down Expand Up @@ -254,7 +246,7 @@ function! vimunit#util#parseVerboseFile(filename)
call VULog('line')
let results[currentfunction]['offset'] = str2nr(substitute(line,'^\v\s*line (\d+):','\=submatch(1)',''))
let results[currentfunction]['detail'] = substitute(line,'^\v.*: (.*)$','\=submatch(1)','')
call VULog('line: '. results[currentfunction]['offset'] )
call VULog(currentfunction .' line: '. results[currentfunction]['offset'] )
else
call VULog('unused line (cf): '. line)
endif
Expand All @@ -266,3 +258,19 @@ function! vimunit#util#parseVerboseFile(filename)
return results
endfunction

function! s:setupkey(line,results,pattern)
let currentfunction = substitute(a:line,a:pattern,'\=submatch(1)','')
" if the key doesn't exist, set it up
if !has_key(a:results,currentfunction)
let a:results['_count_'. currentfunction] = 1
else
" if it does exist, set it up, and give it a new unique key
let a:results['_count_'. currentfunction] += 1
let currentfunction = currentfunction .'('. a:results['_count_'. currentfunction] .')'
endif
let a:results[currentfunction] = {}
let a:results[currentfunction]['status'] = 'unknown'
let a:results[currentfunction]['detail'] = ''
call VULog('currentfunction = "'. currentfunction .'"')
return currentfunction
endfunction
Loading

0 comments on commit 35ffbba

Please sign in to comment.